source: node_modules/d3-ease/dist/d3-ease.js

Last change on this file was e4c61dd, checked in by istevanoska <ilinastevanoska@…>, 6 months ago

Prototype 1.1

  • Property mode set to 100644
File size: 5.7 KB
Line 
1// https://d3js.org/d3-ease/ v3.0.1 Copyright 2010-2021 Mike Bostock, 2001 Robert Penner
2(function (global, factory) {
3typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
4typeof define === 'function' && define.amd ? define(['exports'], factory) :
5(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.d3 = global.d3 || {}));
6}(this, (function (exports) { 'use strict';
7
8const linear = t => +t;
9
10function quadIn(t) {
11 return t * t;
12}
13
14function quadOut(t) {
15 return t * (2 - t);
16}
17
18function quadInOut(t) {
19 return ((t *= 2) <= 1 ? t * t : --t * (2 - t) + 1) / 2;
20}
21
22function cubicIn(t) {
23 return t * t * t;
24}
25
26function cubicOut(t) {
27 return --t * t * t + 1;
28}
29
30function cubicInOut(t) {
31 return ((t *= 2) <= 1 ? t * t * t : (t -= 2) * t * t + 2) / 2;
32}
33
34var exponent = 3;
35
36var polyIn = (function custom(e) {
37 e = +e;
38
39 function polyIn(t) {
40 return Math.pow(t, e);
41 }
42
43 polyIn.exponent = custom;
44
45 return polyIn;
46})(exponent);
47
48var polyOut = (function custom(e) {
49 e = +e;
50
51 function polyOut(t) {
52 return 1 - Math.pow(1 - t, e);
53 }
54
55 polyOut.exponent = custom;
56
57 return polyOut;
58})(exponent);
59
60var polyInOut = (function custom(e) {
61 e = +e;
62
63 function polyInOut(t) {
64 return ((t *= 2) <= 1 ? Math.pow(t, e) : 2 - Math.pow(2 - t, e)) / 2;
65 }
66
67 polyInOut.exponent = custom;
68
69 return polyInOut;
70})(exponent);
71
72var pi = Math.PI,
73 halfPi = pi / 2;
74
75function sinIn(t) {
76 return (+t === 1) ? 1 : 1 - Math.cos(t * halfPi);
77}
78
79function sinOut(t) {
80 return Math.sin(t * halfPi);
81}
82
83function sinInOut(t) {
84 return (1 - Math.cos(pi * t)) / 2;
85}
86
87// tpmt is two power minus ten times t scaled to [0,1]
88function tpmt(x) {
89 return (Math.pow(2, -10 * x) - 0.0009765625) * 1.0009775171065494;
90}
91
92function expIn(t) {
93 return tpmt(1 - +t);
94}
95
96function expOut(t) {
97 return 1 - tpmt(t);
98}
99
100function expInOut(t) {
101 return ((t *= 2) <= 1 ? tpmt(1 - t) : 2 - tpmt(t - 1)) / 2;
102}
103
104function circleIn(t) {
105 return 1 - Math.sqrt(1 - t * t);
106}
107
108function circleOut(t) {
109 return Math.sqrt(1 - --t * t);
110}
111
112function circleInOut(t) {
113 return ((t *= 2) <= 1 ? 1 - Math.sqrt(1 - t * t) : Math.sqrt(1 - (t -= 2) * t) + 1) / 2;
114}
115
116var b1 = 4 / 11,
117 b2 = 6 / 11,
118 b3 = 8 / 11,
119 b4 = 3 / 4,
120 b5 = 9 / 11,
121 b6 = 10 / 11,
122 b7 = 15 / 16,
123 b8 = 21 / 22,
124 b9 = 63 / 64,
125 b0 = 1 / b1 / b1;
126
127function bounceIn(t) {
128 return 1 - bounceOut(1 - t);
129}
130
131function bounceOut(t) {
132 return (t = +t) < b1 ? b0 * t * t : t < b3 ? b0 * (t -= b2) * t + b4 : t < b6 ? b0 * (t -= b5) * t + b7 : b0 * (t -= b8) * t + b9;
133}
134
135function bounceInOut(t) {
136 return ((t *= 2) <= 1 ? 1 - bounceOut(1 - t) : bounceOut(t - 1) + 1) / 2;
137}
138
139var overshoot = 1.70158;
140
141var backIn = (function custom(s) {
142 s = +s;
143
144 function backIn(t) {
145 return (t = +t) * t * (s * (t - 1) + t);
146 }
147
148 backIn.overshoot = custom;
149
150 return backIn;
151})(overshoot);
152
153var backOut = (function custom(s) {
154 s = +s;
155
156 function backOut(t) {
157 return --t * t * ((t + 1) * s + t) + 1;
158 }
159
160 backOut.overshoot = custom;
161
162 return backOut;
163})(overshoot);
164
165var backInOut = (function custom(s) {
166 s = +s;
167
168 function backInOut(t) {
169 return ((t *= 2) < 1 ? t * t * ((s + 1) * t - s) : (t -= 2) * t * ((s + 1) * t + s) + 2) / 2;
170 }
171
172 backInOut.overshoot = custom;
173
174 return backInOut;
175})(overshoot);
176
177var tau = 2 * Math.PI,
178 amplitude = 1,
179 period = 0.3;
180
181var elasticIn = (function custom(a, p) {
182 var s = Math.asin(1 / (a = Math.max(1, a))) * (p /= tau);
183
184 function elasticIn(t) {
185 return a * tpmt(-(--t)) * Math.sin((s - t) / p);
186 }
187
188 elasticIn.amplitude = function(a) { return custom(a, p * tau); };
189 elasticIn.period = function(p) { return custom(a, p); };
190
191 return elasticIn;
192})(amplitude, period);
193
194var elasticOut = (function custom(a, p) {
195 var s = Math.asin(1 / (a = Math.max(1, a))) * (p /= tau);
196
197 function elasticOut(t) {
198 return 1 - a * tpmt(t = +t) * Math.sin((t + s) / p);
199 }
200
201 elasticOut.amplitude = function(a) { return custom(a, p * tau); };
202 elasticOut.period = function(p) { return custom(a, p); };
203
204 return elasticOut;
205})(amplitude, period);
206
207var elasticInOut = (function custom(a, p) {
208 var s = Math.asin(1 / (a = Math.max(1, a))) * (p /= tau);
209
210 function elasticInOut(t) {
211 return ((t = t * 2 - 1) < 0
212 ? a * tpmt(-t) * Math.sin((s - t) / p)
213 : 2 - a * tpmt(t) * Math.sin((s + t) / p)) / 2;
214 }
215
216 elasticInOut.amplitude = function(a) { return custom(a, p * tau); };
217 elasticInOut.period = function(p) { return custom(a, p); };
218
219 return elasticInOut;
220})(amplitude, period);
221
222exports.easeBack = backInOut;
223exports.easeBackIn = backIn;
224exports.easeBackInOut = backInOut;
225exports.easeBackOut = backOut;
226exports.easeBounce = bounceOut;
227exports.easeBounceIn = bounceIn;
228exports.easeBounceInOut = bounceInOut;
229exports.easeBounceOut = bounceOut;
230exports.easeCircle = circleInOut;
231exports.easeCircleIn = circleIn;
232exports.easeCircleInOut = circleInOut;
233exports.easeCircleOut = circleOut;
234exports.easeCubic = cubicInOut;
235exports.easeCubicIn = cubicIn;
236exports.easeCubicInOut = cubicInOut;
237exports.easeCubicOut = cubicOut;
238exports.easeElastic = elasticOut;
239exports.easeElasticIn = elasticIn;
240exports.easeElasticInOut = elasticInOut;
241exports.easeElasticOut = elasticOut;
242exports.easeExp = expInOut;
243exports.easeExpIn = expIn;
244exports.easeExpInOut = expInOut;
245exports.easeExpOut = expOut;
246exports.easeLinear = linear;
247exports.easePoly = polyInOut;
248exports.easePolyIn = polyIn;
249exports.easePolyInOut = polyInOut;
250exports.easePolyOut = polyOut;
251exports.easeQuad = quadInOut;
252exports.easeQuadIn = quadIn;
253exports.easeQuadInOut = quadInOut;
254exports.easeQuadOut = quadOut;
255exports.easeSin = sinInOut;
256exports.easeSinIn = sinIn;
257exports.easeSinInOut = sinInOut;
258exports.easeSinOut = sinOut;
259
260Object.defineProperty(exports, '__esModule', { value: true });
261
262})));
Note: See TracBrowser for help on using the repository browser.