MCPcopy
hub / github.com/toorshia/justgage / _applyEasing

Method _applyEasing

src/core/GaugeAnimator.js:86–124  ·  view source on GitHub ↗

* Apply easing function to progress * Ref: https://github.com/DmitryBaranovskiy/raphael/blob/master/raphael.js#L4161 * @private

(progress, easing)

Source from the content-addressed store, hash-verified

84 * @private
85 */
86 _applyEasing(progress, easing) {
87 switch (easing) {
88 case 'linear':
89 case '-':
90 return progress;
91 case '>':
92 case 'easeOut':
93 case 'ease-out':
94 return Math.pow(progress, 0.48);
95 case '<':
96 case 'easeIn':
97 case 'ease-in':
98 return Math.pow(progress, 1.7);
99 case '<>':
100 case 'easeInOut':
101 case 'ease-in-out':
102 return progress < 0.5 ? 2 * progress * progress : 1 - Math.pow(-2 * progress + 2, 2) / 2;
103 case 'bounce':
104 return this._bounceEasing(progress);
105 case 'elastic':
106 return (
107 Math.pow(2, -10 * progress) * Math.sin(((progress - 0.075) * (2 * Math.PI)) / 0.3) + 1
108 );
109 case 'backIn':
110 case 'back-in': {
111 const c1 = 1.70158;
112 const c3 = c1 + 1;
113 return c3 * progress * progress * progress - c1 * progress * progress;
114 }
115 case 'backOut':
116 case 'back-out': {
117 const c2 = 1.70158;
118 const c4 = c2 + 1;
119 return 1 + c4 * Math.pow(progress - 1, 3) + c2 * Math.pow(progress - 1, 2);
120 }
121 default:
122 return progress;
123 }
124 }
125
126 /**
127 * Bounce easing function

Callers 1

animateMethod · 0.95

Calls 1

_bounceEasingMethod · 0.95

Tested by

no test coverage detected