Skip to content

Commit

Permalink
autoSmooth -> smartEasing
Browse files Browse the repository at this point in the history
  • Loading branch information
inorganik committed Feb 21, 2019
1 parent 89353d8 commit ab40ea9
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 22 deletions.
20 changes: 12 additions & 8 deletions dist/countUp.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ var __assign = (this && this.__assign) || function () {
duration: 2,
useEasing: true,
useGrouping: true,
autoSmoothThreshold: 999,
autoSmoothAmount: 333,
smartEaseEnabled: true,
smartEaseThreshold: 999,
smartEaseAmount: 333,
separator: ',',
decimal: '.',
prefix: '',
Expand Down Expand Up @@ -149,13 +150,16 @@ var __assign = (this && this.__assign) || function () {
this.error = '[CountUp] target is null or undefined';
}
}
CountUp.prototype.determineIfWillAutoSmooth = function (start, end) {
CountUp.prototype.determineCountDownAndSmartEase = function (start, end) {
this.countDown = (start > end);
if (!this.options.smartEaseEnabled) {
return;
}
var animateAmount = end - start;
this.countDown = (this.startVal > this.endVal);
if (Math.abs(animateAmount) > this.options.autoSmoothThreshold) {
if (Math.abs(animateAmount) > this.options.smartEaseThreshold) {
this.finalEndVal = end;
var up = (this.countDown) ? 1 : -1;
this.endVal = this.endVal + (up * this.options.autoSmoothAmount);
this.endVal = this.endVal + (up * this.options.smartEaseAmount);
this.duration = this.duration / 2;
}
else {
Expand All @@ -177,7 +181,7 @@ var __assign = (this && this.__assign) || function () {
this.callback = callback;
if (this.duration > 0) {
// auto-smooth large numbers
this.determineIfWillAutoSmooth(this.startVal, this.endVal);
this.determineCountDownAndSmartEase(this.startVal, this.endVal);
this.paused = false;
this.rAF = requestAnimationFrame(this.count);
}
Expand Down Expand Up @@ -221,7 +225,7 @@ var __assign = (this && this.__assign) || function () {
}
this.finalEndVal = null;
this.startVal = this.frameVal;
this.determineIfWillAutoSmooth(this.startVal, this.endVal);
this.determineCountDownAndSmartEase(this.startVal, this.endVal);
this.rAF = requestAnimationFrame(this.count);
};
CountUp.prototype.printValue = function (val) {
Expand Down
2 changes: 1 addition & 1 deletion dist/countUp.legacy.min.js

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

Loading

0 comments on commit ab40ea9

Please sign in to comment.