| 1 | // https://d3js.org/d3-ease/ v3.0.1 Copyright 2010-2021 Mike Bostock, 2001 Robert Penner
|
|---|
| 2 | (function (global, factory) {
|
|---|
| 3 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|---|
| 4 | typeof 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 |
|
|---|
| 8 | const linear = t => +t;
|
|---|
| 9 |
|
|---|
| 10 | function quadIn(t) {
|
|---|
| 11 | return t * t;
|
|---|
| 12 | }
|
|---|
| 13 |
|
|---|
| 14 | function quadOut(t) {
|
|---|
| 15 | return t * (2 - t);
|
|---|
| 16 | }
|
|---|
| 17 |
|
|---|
| 18 | function quadInOut(t) {
|
|---|
| 19 | return ((t *= 2) <= 1 ? t * t : --t * (2 - t) + 1) / 2;
|
|---|
| 20 | }
|
|---|
| 21 |
|
|---|
| 22 | function cubicIn(t) {
|
|---|
| 23 | return t * t * t;
|
|---|
| 24 | }
|
|---|
| 25 |
|
|---|
| 26 | function cubicOut(t) {
|
|---|
| 27 | return --t * t * t + 1;
|
|---|
| 28 | }
|
|---|
| 29 |
|
|---|
| 30 | function cubicInOut(t) {
|
|---|
| 31 | return ((t *= 2) <= 1 ? t * t * t : (t -= 2) * t * t + 2) / 2;
|
|---|
| 32 | }
|
|---|
| 33 |
|
|---|
| 34 | var exponent = 3;
|
|---|
| 35 |
|
|---|
| 36 | var 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 |
|
|---|
| 48 | var 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 |
|
|---|
| 60 | var 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 |
|
|---|
| 72 | var pi = Math.PI,
|
|---|
| 73 | halfPi = pi / 2;
|
|---|
| 74 |
|
|---|
| 75 | function sinIn(t) {
|
|---|
| 76 | return (+t === 1) ? 1 : 1 - Math.cos(t * halfPi);
|
|---|
| 77 | }
|
|---|
| 78 |
|
|---|
| 79 | function sinOut(t) {
|
|---|
| 80 | return Math.sin(t * halfPi);
|
|---|
| 81 | }
|
|---|
| 82 |
|
|---|
| 83 | function 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]
|
|---|
| 88 | function tpmt(x) {
|
|---|
| 89 | return (Math.pow(2, -10 * x) - 0.0009765625) * 1.0009775171065494;
|
|---|
| 90 | }
|
|---|
| 91 |
|
|---|
| 92 | function expIn(t) {
|
|---|
| 93 | return tpmt(1 - +t);
|
|---|
| 94 | }
|
|---|
| 95 |
|
|---|
| 96 | function expOut(t) {
|
|---|
| 97 | return 1 - tpmt(t);
|
|---|
| 98 | }
|
|---|
| 99 |
|
|---|
| 100 | function expInOut(t) {
|
|---|
| 101 | return ((t *= 2) <= 1 ? tpmt(1 - t) : 2 - tpmt(t - 1)) / 2;
|
|---|
| 102 | }
|
|---|
| 103 |
|
|---|
| 104 | function circleIn(t) {
|
|---|
| 105 | return 1 - Math.sqrt(1 - t * t);
|
|---|
| 106 | }
|
|---|
| 107 |
|
|---|
| 108 | function circleOut(t) {
|
|---|
| 109 | return Math.sqrt(1 - --t * t);
|
|---|
| 110 | }
|
|---|
| 111 |
|
|---|
| 112 | function circleInOut(t) {
|
|---|
| 113 | return ((t *= 2) <= 1 ? 1 - Math.sqrt(1 - t * t) : Math.sqrt(1 - (t -= 2) * t) + 1) / 2;
|
|---|
| 114 | }
|
|---|
| 115 |
|
|---|
| 116 | var 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 |
|
|---|
| 127 | function bounceIn(t) {
|
|---|
| 128 | return 1 - bounceOut(1 - t);
|
|---|
| 129 | }
|
|---|
| 130 |
|
|---|
| 131 | function 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 |
|
|---|
| 135 | function bounceInOut(t) {
|
|---|
| 136 | return ((t *= 2) <= 1 ? 1 - bounceOut(1 - t) : bounceOut(t - 1) + 1) / 2;
|
|---|
| 137 | }
|
|---|
| 138 |
|
|---|
| 139 | var overshoot = 1.70158;
|
|---|
| 140 |
|
|---|
| 141 | var 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 |
|
|---|
| 153 | var 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 |
|
|---|
| 165 | var 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 |
|
|---|
| 177 | var tau = 2 * Math.PI,
|
|---|
| 178 | amplitude = 1,
|
|---|
| 179 | period = 0.3;
|
|---|
| 180 |
|
|---|
| 181 | var 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 |
|
|---|
| 194 | var 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 |
|
|---|
| 207 | var 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 |
|
|---|
| 222 | exports.easeBack = backInOut;
|
|---|
| 223 | exports.easeBackIn = backIn;
|
|---|
| 224 | exports.easeBackInOut = backInOut;
|
|---|
| 225 | exports.easeBackOut = backOut;
|
|---|
| 226 | exports.easeBounce = bounceOut;
|
|---|
| 227 | exports.easeBounceIn = bounceIn;
|
|---|
| 228 | exports.easeBounceInOut = bounceInOut;
|
|---|
| 229 | exports.easeBounceOut = bounceOut;
|
|---|
| 230 | exports.easeCircle = circleInOut;
|
|---|
| 231 | exports.easeCircleIn = circleIn;
|
|---|
| 232 | exports.easeCircleInOut = circleInOut;
|
|---|
| 233 | exports.easeCircleOut = circleOut;
|
|---|
| 234 | exports.easeCubic = cubicInOut;
|
|---|
| 235 | exports.easeCubicIn = cubicIn;
|
|---|
| 236 | exports.easeCubicInOut = cubicInOut;
|
|---|
| 237 | exports.easeCubicOut = cubicOut;
|
|---|
| 238 | exports.easeElastic = elasticOut;
|
|---|
| 239 | exports.easeElasticIn = elasticIn;
|
|---|
| 240 | exports.easeElasticInOut = elasticInOut;
|
|---|
| 241 | exports.easeElasticOut = elasticOut;
|
|---|
| 242 | exports.easeExp = expInOut;
|
|---|
| 243 | exports.easeExpIn = expIn;
|
|---|
| 244 | exports.easeExpInOut = expInOut;
|
|---|
| 245 | exports.easeExpOut = expOut;
|
|---|
| 246 | exports.easeLinear = linear;
|
|---|
| 247 | exports.easePoly = polyInOut;
|
|---|
| 248 | exports.easePolyIn = polyIn;
|
|---|
| 249 | exports.easePolyInOut = polyInOut;
|
|---|
| 250 | exports.easePolyOut = polyOut;
|
|---|
| 251 | exports.easeQuad = quadInOut;
|
|---|
| 252 | exports.easeQuadIn = quadIn;
|
|---|
| 253 | exports.easeQuadInOut = quadInOut;
|
|---|
| 254 | exports.easeQuadOut = quadOut;
|
|---|
| 255 | exports.easeSin = sinInOut;
|
|---|
| 256 | exports.easeSinIn = sinIn;
|
|---|
| 257 | exports.easeSinInOut = sinInOut;
|
|---|
| 258 | exports.easeSinOut = sinOut;
|
|---|
| 259 |
|
|---|
| 260 | Object.defineProperty(exports, '__esModule', { value: true });
|
|---|
| 261 |
|
|---|
| 262 | })));
|
|---|