Skip to content

Commit

Permalink
fix the bug (#287)
Browse files Browse the repository at this point in the history
  • Loading branch information
inorganik committed Jul 7, 2022
1 parent 6c607d9 commit 4767952
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 31 deletions.
19 changes: 5 additions & 14 deletions dist/countUp.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,11 @@ var CountUp = /** @class */ (function () {
}
}
else {
if (_this.countDown) {
_this.frameVal = _this.startVal - ((_this.startVal - _this.endVal) * (progress / _this.duration));
}
else {
_this.frameVal = _this.startVal + (_this.endVal - _this.startVal) * (progress / _this.duration);
}
_this.frameVal = _this.startVal + (_this.endVal - _this.startVal) * (progress / _this.duration);
}
// don't go past endVal since progress can exceed duration in the last frame
if (_this.countDown) {
_this.frameVal = (_this.frameVal < _this.endVal) ? _this.endVal : _this.frameVal;
}
else {
_this.frameVal = (_this.frameVal > _this.endVal) ? _this.endVal : _this.frameVal;
}
var wentPast = _this.countDown ? _this.frameVal < _this.endVal : _this.frameVal > _this.endVal;
_this.frameVal = wentPast ? _this.endVal : _this.frameVal;
// decimal
_this.frameVal = Number(_this.frameVal.toFixed(_this.options.decimalPlaces));
// format and print value
Expand Down Expand Up @@ -179,7 +170,7 @@ var CountUp = /** @class */ (function () {
var animateAmount = end - this.startVal;
console.log('end', end, 'animate amount', animateAmount);
console.log('abs animate amount', Math.abs(animateAmount));
if (Math.abs(animateAmount) > this.options.smartEasingThreshold) {
if (Math.abs(animateAmount) > this.options.smartEasingThreshold && this.options.useEasing) {
this.finalEndVal = end;
var up = (this.countDown) ? 1 : -1;
this.endVal = end + (up * this.options.smartEasingAmount);
Expand Down Expand Up @@ -243,7 +234,7 @@ var CountUp = /** @class */ (function () {
return;
}
this.startVal = this.frameVal;
if (!this.finalEndVal) {
if (this.finalEndVal == null) {
this.resetDuration();
}
this.finalEndVal = null;
Expand Down
2 changes: 1 addition & 1 deletion dist/countUp.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 5 additions & 14 deletions dist/countUp.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,11 @@
}
}
else {
if (_this.countDown) {
_this.frameVal = _this.startVal - ((_this.startVal - _this.endVal) * (progress / _this.duration));
}
else {
_this.frameVal = _this.startVal + (_this.endVal - _this.startVal) * (progress / _this.duration);
}
_this.frameVal = _this.startVal + (_this.endVal - _this.startVal) * (progress / _this.duration);
}
// don't go past endVal since progress can exceed duration in the last frame
if (_this.countDown) {
_this.frameVal = (_this.frameVal < _this.endVal) ? _this.endVal : _this.frameVal;
}
else {
_this.frameVal = (_this.frameVal > _this.endVal) ? _this.endVal : _this.frameVal;
}
var wentPast = _this.countDown ? _this.frameVal < _this.endVal : _this.frameVal > _this.endVal;
_this.frameVal = wentPast ? _this.endVal : _this.frameVal;
// decimal
_this.frameVal = Number(_this.frameVal.toFixed(_this.options.decimalPlaces));
// format and print value
Expand Down Expand Up @@ -185,7 +176,7 @@
var animateAmount = end - this.startVal;
console.log('end', end, 'animate amount', animateAmount);
console.log('abs animate amount', Math.abs(animateAmount));
if (Math.abs(animateAmount) > this.options.smartEasingThreshold) {
if (Math.abs(animateAmount) > this.options.smartEasingThreshold && this.options.useEasing) {
this.finalEndVal = end;
var up = (this.countDown) ? 1 : -1;
this.endVal = end + (up * this.options.smartEasingAmount);
Expand Down Expand Up @@ -249,7 +240,7 @@
return;
}
this.startVal = this.frameVal;
if (!this.finalEndVal) {
if (this.finalEndVal == null) {
this.resetDuration();
}
this.finalEndVal = null;
Expand Down
Loading

0 comments on commit 4767952

Please sign in to comment.