popmotion
Advanced tools
Comparing version 9.0.0-rc.19 to 9.0.0-rc.20
@@ -1,2 +0,2 @@ | ||
import { __assign, __spreadArrays, __rest } from 'tslib'; | ||
import { __rest, __assign, __spreadArrays } from 'tslib'; | ||
import { warning, invariant } from 'hey-listen'; | ||
@@ -88,2 +88,18 @@ import { hex, rgba, hsla, complex, color } from 'style-value-types'; | ||
var durationKeys = ["duration", "bounce"]; | ||
var physicsKeys = ["stiffness", "damping", "mass"]; | ||
function isSpringType(options, keys) { | ||
return keys.some(function (key) { | ||
return options[key] !== undefined; | ||
}); | ||
} | ||
function getSpringOptions(options) { | ||
var springOptions = __assign({ velocity: 0.0, stiffness: 100, damping: 10, mass: 1.0, isResolvedFromDuration: false }, options); | ||
if (!isSpringType(options, physicsKeys) && isSpringType(options, durationKeys)) { | ||
var derived = findSpring(options); | ||
springOptions = __assign(__assign(__assign({}, springOptions), derived), { velocity: 0.0, mass: 1.0 }); | ||
springOptions.isResolvedFromDuration = true; | ||
} | ||
return springOptions; | ||
} | ||
function spring(_a) { | ||
@@ -94,25 +110,13 @@ var _b = _a.from, | ||
to = _c === void 0 ? 1.0 : _c, | ||
_d = _a.velocity, | ||
velocity = _d === void 0 ? 0.0 : _d, | ||
_e = _a.stiffness, | ||
stiffness = _e === void 0 ? 100 : _e, | ||
_f = _a.damping, | ||
damping = _f === void 0 ? 10 : _f, | ||
_g = _a.mass, | ||
mass = _g === void 0 ? 1.0 : _g, | ||
_h = _a.restSpeed, | ||
restSpeed = _h === void 0 ? 2 : _h, | ||
_d = _a.restSpeed, | ||
restSpeed = _d === void 0 ? 2 : _d, | ||
restDelta = _a.restDelta, | ||
duration = _a.duration, | ||
bounce = _a.bounce; | ||
var isResolvedFromDuration = false; | ||
options = __rest(_a, ["from", "to", "restSpeed", "restDelta"]); | ||
var state = { done: false, value: from }; | ||
if (duration !== undefined || bounce !== undefined) { | ||
isResolvedFromDuration = true; | ||
var derived = findSpring({ duration: duration, bounce: bounce }); | ||
stiffness = derived.stiffness; | ||
damping = derived.damping; | ||
velocity = 0.0; | ||
mass = 1.0; | ||
} | ||
var _e = getSpringOptions(options), | ||
stiffness = _e.stiffness, | ||
damping = _e.damping, | ||
mass = _e.mass, | ||
velocity = _e.velocity, | ||
isResolvedFromDuration = _e.isResolvedFromDuration; | ||
var resolveSpring = zero; | ||
@@ -159,3 +163,3 @@ var resolveVelocity = zero; | ||
} else { | ||
state.done = t >= duration; | ||
state.done = t >= options.duration; | ||
} | ||
@@ -162,0 +166,0 @@ state.value = state.done ? to : current; |
@@ -145,14 +145,21 @@ (function (global, factory) { | ||
var durationKeys = ["duration", "bounce"]; | ||
var physicsKeys = ["stiffness", "damping", "mass"]; | ||
function isSpringType(options, keys) { | ||
return keys.some(function (key) { return options[key] !== undefined; }); | ||
} | ||
function getSpringOptions(options) { | ||
var springOptions = __assign({ velocity: 0.0, stiffness: 100, damping: 10, mass: 1.0, isResolvedFromDuration: false }, options); | ||
if (!isSpringType(options, physicsKeys) && | ||
isSpringType(options, durationKeys)) { | ||
var derived = findSpring(options); | ||
springOptions = __assign(__assign(__assign({}, springOptions), derived), { velocity: 0.0, mass: 1.0 }); | ||
springOptions.isResolvedFromDuration = true; | ||
} | ||
return springOptions; | ||
} | ||
function spring(_a) { | ||
var _b = _a.from, from = _b === void 0 ? 0.0 : _b, _c = _a.to, to = _c === void 0 ? 1.0 : _c, _d = _a.velocity, velocity = _d === void 0 ? 0.0 : _d, _e = _a.stiffness, stiffness = _e === void 0 ? 100 : _e, _f = _a.damping, damping = _f === void 0 ? 10 : _f, _g = _a.mass, mass = _g === void 0 ? 1.0 : _g, _h = _a.restSpeed, restSpeed = _h === void 0 ? 2 : _h, restDelta = _a.restDelta, duration = _a.duration, bounce = _a.bounce; | ||
var isResolvedFromDuration = false; | ||
var _b = _a.from, from = _b === void 0 ? 0.0 : _b, _c = _a.to, to = _c === void 0 ? 1.0 : _c, _d = _a.restSpeed, restSpeed = _d === void 0 ? 2 : _d, restDelta = _a.restDelta, options = __rest(_a, ["from", "to", "restSpeed", "restDelta"]); | ||
var state = { done: false, value: from }; | ||
if (duration !== undefined || bounce !== undefined) { | ||
isResolvedFromDuration = true; | ||
var derived = findSpring({ duration: duration, bounce: bounce }); | ||
stiffness = derived.stiffness; | ||
damping = derived.damping; | ||
velocity = 0.0; | ||
mass = 1.0; | ||
} | ||
var _e = getSpringOptions(options), stiffness = _e.stiffness, damping = _e.damping, mass = _e.mass, velocity = _e.velocity, isResolvedFromDuration = _e.isResolvedFromDuration; | ||
var resolveSpring = zero; | ||
@@ -239,3 +246,3 @@ var resolveVelocity = zero; | ||
else { | ||
state.done = t >= duration; | ||
state.done = t >= options.duration; | ||
} | ||
@@ -242,0 +249,0 @@ state.value = state.done ? to : current; |
@@ -1,1 +0,1 @@ | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n=n||self).popmotion={})}(this,function(n){"use strict";var k=function(){return(k=Object.assign||function(n){for(var t,r=1,e=arguments.length;r<e;r++)for(var a in t=arguments[r])Object.prototype.hasOwnProperty.call(t,a)&&(n[a]=t[a]);return n}).apply(this,arguments)};var b=function(){},x=function(n,t,r){return Math.min(Math.max(r,n),t)},l=.001,h=.01,m=10,y=.05,g=1;function A(n){var u,t=n.duration,i=void 0===t?800:t,r=n.bounce,e=void 0===r?.25:r,a=n.velocity,f=void 0===a?0:a,o=n.mass,s=void 0===o?1:o,c=x(y,g,c=1-e),i=x(h,m,i/1e3),p=c<1?(u=function(n){var t=n*c,r=t*i,e=t-f,a=I(n,c),o=Math.exp(-r);return l-e/a*o},function(n){var t=n*c*i,r=t*f+f,e=Math.pow(c,2)*Math.pow(n,2)*i,a=Math.exp(-t),o=I(Math.pow(n,2),c);return(r-e)*a*(0<-u(n)+l?-1:1)/o}):(u=function(n){return Math.exp(-n*i)*((n-f)*i+1)-l},function(n){return Math.exp(-n*i)*(i*i*(f-n))}),v=function(n,t,r){for(var e=r,a=1;a<M;a++)e-=n(e)/t(e);return e}(u,p,5/i);if(isNaN(v))return{stiffness:100,damping:10};var d=Math.pow(v,2)*s;return{stiffness:d,damping:2*c*Math.sqrt(s*d)}}var M=12;function I(n,t){return n*Math.sqrt(1-t*t)}function C(n){var t,r=n.from,f=void 0===r?0:r,e=n.to,s=void 0===e?1:e,a=n.velocity,c=void 0===a?0:a,o=n.stiffness,p=void 0===o?100:o,u=n.damping,v=void 0===u?10:u,i=n.mass,d=void 0===i?1:i,l=n.restSpeed,h=void 0===l?2:l,m=n.restDelta,y=n.duration,g=n.bounce,M=!1,b={done:!1,value:f};void 0===y&&void 0===g||(M=!0,t=A({duration:y,bounce:g}),p=t.stiffness,v=t.damping,c=0,d=1);var x=P,w=P;function O(){var r,e,a=c?-c/1e3:0,o=s-f,u=v/(2*Math.sqrt(p*d)),i=Math.sqrt(p/d)/1e3;null!=m||(m=Math.abs(s-f)<=1?.01:.4),u<1?(r=I(i,u),x=function(n){var t=Math.exp(-u*i*n);return s-t*((a+u*i*o)/r*Math.sin(r*n)+o*Math.cos(r*n))},w=function(n){var t=Math.exp(-u*i*n);return u*i*t*(Math.sin(r*n)*(a+u*i*o)/r+o*Math.cos(r*n))-t*(Math.cos(r*n)*(a+u*i*o)-r*o*Math.sin(r*n))}):x=1==u?function(n){return s-Math.exp(-i*n)*(o+(a+i*o)*n)}:(e=i*Math.sqrt(u*u-1),function(n){var t=Math.exp(-u*i*n),r=Math.min(e*n,300);return s-t*((a+u*i*o)*Math.sinh(r)+e*o*Math.cosh(r))/e})}return O(),{next:function(n){var t,r,e,a=x(n);return M?b.done=y<=n:(t=1e3*w(n),r=Math.abs(t)<=h,e=Math.abs(s-a)<=m,b.done=r&&e),b.value=b.done?s:a,b},flipTarget:function(){var n;c=-c,f=(n=[s,f])[0],s=n[1],O()}}}C.needsInterpolation=function(n,t){return"string"==typeof n||"string"==typeof t};function f(n,t,r){return-r*n+r*t+n}function t(t,r){return function(n){return Math.max(Math.min(n,r),t)}}function p(n){return n%1?Number(n.toFixed(5)):n}function r(n){return void 0!==n.red}function e(n){return void 0!==n.hue}var a,P=function(n){return 0},w=function(n,t,r){var e=t-n;return 0==e?1:(r-n)/e},s=/(-)?(\d[\d\.]*)/g,c=/(#[0-9a-f]{6}|#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))/gi,o=/^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))$/i,u={test:function(n){return"number"==typeof n},parse:parseFloat,transform:function(n){return n}},v=k(k({},u),{transform:t(0,1)}),d=(k(k({},u),{default:1}),a="%",{test:function(n){return"string"==typeof n&&n.endsWith(a)&&1===n.split(" ").length},parse:parseFloat,transform:function(n){return""+n+a}}),i=(k(k({},d),{parse:function(n){return d.parse(n)/100},transform:function(n){return d.transform(100*n)}}),t(0,255));function O(o){return function(n){if("string"!=typeof n)return n;for(var t,r={},e=(t=n).substring(t.indexOf("(")+1,t.lastIndexOf(")")).replace(/(,|\/)/g," ").split(/ \s*/),a=0;a<4;a++)r[o[a]]=void 0!==e[a]?parseFloat(e[a]):1;return r}}var T=k(k({},u),{transform:function(n){return Math.round(i(n))}});function D(n,t){return n.startsWith(t)&&o.test(n)}function S(n){return"number"==typeof n?0:n}function j(n,t,r){var e=n*n,a=t*t;return Math.sqrt(Math.max(0,r*(a-e)+e))}function q(t){return _.find(function(n){return n.test(t)})}function F(n){return"number"==typeof n}function R(t,r){return function(n){return r(t(n))}}var N={test:function(n){return"string"==typeof n?D(n,"rgb"):r(n)},parse:O(["red","green","blue","alpha"]),transform:function(n){var t,r,e,a,o,u=n.red,i=n.green,f=n.blue,s=n.alpha,c=void 0===s?1:s;return t={red:T.transform(u),green:T.transform(i),blue:T.transform(f),alpha:p(v.transform(c))},r=t.red,e=t.green,a=t.blue,o=t.alpha,"rgba("+r+", "+e+", "+a+", "+(void 0===o?1:o)+")"}},E={test:function(n){return"string"==typeof n?D(n,"hsl"):e(n)},parse:O(["hue","saturation","lightness","alpha"]),transform:function(n){var t,r,e,a,o,u=n.hue,i=n.saturation,f=n.lightness,s=n.alpha,c=void 0===s?1:s;return t={hue:Math.round(u),saturation:d.transform(p(i)),lightness:d.transform(p(f)),alpha:p(v.transform(c))},r=t.hue,e=t.saturation,a=t.lightness,o=t.alpha,"hsla("+r+", "+e+", "+a+", "+(void 0===o?1:o)+")"}},U=k(k({},N),{test:function(n){return"string"==typeof n&&D(n,"#")},parse:function(n){var t="",r="",e="";return 4<n.length?(t=n.substr(1,2),r=n.substr(3,2),e=n.substr(5,2)):(t=n.substr(1,1),r=n.substr(2,1),e=n.substr(3,1),t+=t,r+=r,e+=e),{red:parseInt(t,16),green:parseInt(r,16),blue:parseInt(e,16),alpha:1}}}),z={test:function(n){return"string"==typeof n&&o.test(n)||r(n)||e(n)},parse:function(n){return N.test(n)?N.parse(n):E.test(n)?E.parse(n):U.test(n)?U.parse(n):n},transform:function(n){return r(n)?N.transform(n):e(n)?E.transform(n):n}},W="${c}",B="${n}",$={test:function(n){if("string"!=typeof n||!isNaN(n))return!1;var t=0,r=n.match(s),e=n.match(c);return r&&(t+=r.length),e&&(t+=e.length),0<t},parse:function(n){var t=n,r=[],e=t.match(c);e&&(t=t.replace(c,W),r.push.apply(r,e.map(z.parse)));var a=t.match(s);return a&&r.push.apply(r,a.map(u.parse)),r},createTransformer:function(n){var e=n,a=0,t=n.match(c),o=t?t.length:0;if(t)for(var r=0;r<o;r++)e=e.replace(t[r],W),a++;var u=e.match(s),i=u?u.length:0;if(u)for(r=0;r<i;r++)e=e.replace(u[r],B),a++;return function(n){for(var t=e,r=0;r<a;r++)t=t.replace(r<o?W:B,r<o?z.transform(n[r]):p(n[r]));return t}},getAnimatableNone:function(n){var t=$.parse(n);return $.createTransformer(n)(t.map(S))}},_=[U,N,E],G=function(n,t){var r=q(n),e=q(t);b(r.transform===e.transform);var a=r.parse(n),o=e.parse(t),u=k({},a),i=r===E?f:j;return function(n){for(var t in u)"alpha"!==t&&(u[t]=i(a[t],o[t],n));return u.alpha=f(a.alpha,o.alpha,n),r.transform(u)}},H={x:0,y:0,z:0},L=function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return n.reduce(R)};function V(t,r){return F(t)?function(n){return f(t,r,n)}:(z.test(t)?G:X)(t,r)}var J=function(n,r){var e=function(){for(var n=0,t=0,r=arguments.length;t<r;t++)n+=arguments[t].length;for(var e=Array(n),a=0,t=0;t<r;t++)for(var o=arguments[t],u=0,i=o.length;u<i;u++,a++)e[a]=o[u];return e}(n),a=e.length,o=n.map(function(n,t){return V(n,r[t])});return function(n){for(var t=0;t<a;t++)e[t]=o[t](n);return e}},K=function(n,t){var r=k(k({},n),t),e={};for(var a in r)void 0!==n[a]&&void 0!==t[a]&&(e[a]=V(n[a],t[a]));return function(n){for(var t in e)r[t]=e[t](n);return r}};function Q(n){for(var t=$.parse(n),r=t.length,e=0,a=0,o=0,u=0;u<r;u++)e||"number"==typeof t[u]?e++:void 0!==t[u].hue?o++:a++;return{parsed:t,numNumbers:e,numRGB:a,numHSL:o}}var X=function(n,t){var r=$.createTransformer(t),e=Q(n),a=Q(t);return L(J(e.parsed,a.parsed),r)},Y=function(t,r){return function(n){return f(t,r,n)}};function Z(n,t,r){for(var e,a=[],o=r||("number"==typeof(e=n[0])?Y:"string"==typeof e?z.test(e)?G:X:Array.isArray(e)?J:"object"==typeof e?K:void 0),u=n.length-1,i=0;i<u;i++){var f,s=o(n[i],n[i+1]);t&&(f=Array.isArray(t)?t[i]:t,s=L(f,s)),a.push(s)}return a}function nn(t,n,r){var e=void 0===r?{}:r,a=e.clamp,o=void 0===a||a,u=e.ease,i=e.mixer,f=t.length;b(f===n.length),b(!u||!Array.isArray(u)||u.length===f-1),t[0]>t[f-1]&&(t=[].concat(t),n=[].concat(n),t.reverse(),n.reverse());var s,c,p,v,d,l,h,m,y,g=Z(n,u,i),M=2===f?(l=g,h=(d=t)[0],m=d[1],y=l[0],function(n){return y(w(h,m,n))}):(c=g,p=(s=t).length,v=p-1,function(n){var t=0,r=!1;if(n<=s[0]?r=!0:n>=s[v]&&(t=v-1,r=!0),!r){for(var e=1;e<p&&!(s[e]>n||e===v);e++);t=e-1}var a=w(s[t],s[t+1],n);return c[t](a)});return o?function(n){return M(x(t[0],t[f-1],n))}:M}function tn(t){return function(n){return 1-t(1-n)}}function rn(t){return function(n){return n<=.5?t(2*n)/2:(2-t(2*(1-n)))/2}}function en(t){return function(n){return Math.pow(n,t)}}function an(t){return function(n){return n*n*((t+1)*n-t)}}function on(n){var t=an(n);return function(n){return(n*=2)<1?.5*t(n):.5*(2-Math.pow(2,-10*(n-1)))}}function un(n){return n}function fn(n){return 1-Math.sin(Math.acos(n))}function sn(n){if(1===n||0===n)return n;var t=n*n;return n<4/11?7.5625*t:n<8/11?9.075*t-9.9*n+3.4:n<.9?4356/361*t-35442/1805*n+16061/1805:10.8*n*n-20.52*n+10.72}var cn=en(2),pn=tn(cn),vn=rn(cn),dn=tn(fn),ln=rn(dn),hn=an(1.525),mn=tn(hn),yn=rn(hn),gn=on(1.525),Mn=tn(sn);function bn(n){var t,r,e,a,o=n.from,u=void 0===o?0:o,i=n.to,f=void 0===i?1:i,s=n.ease,c=n.offset,p=n.duration,v=void 0===p?300:p,d={done:!1,value:u},l=Array.isArray(f)?f:[u,f],h=(t=null!=c?c:(a=(e=l).length,e.map(function(n,t){return 0!==t?t/(a-1):0})),r=v,t.map(function(n){return n*r}));function m(){return nn(h,l,{ease:Array.isArray(s)?s:(t=s,(n=l).map(function(){return t||vn}).splice(0,n.length-1))});var n,t}var y=m();return{next:function(n){return d.value=y(n),d.done=v<=n,d},flipTarget:function(){l.reverse(),y=m()}}}function xn(n){var t=n.velocity,r=void 0===t?0:t,e=n.from,a=void 0===e?0:e,o=n.power,u=void 0===o?.8:o,i=n.timeConstant,f=void 0===i?350:i,s=n.restDelta,c=void 0===s?.5:s,p=n.modifyTarget,v={done:!1,value:a},d=u*r,l=a+d,h=void 0===p?l:p(l);return h!==l&&(d=h-a),{next:function(n){var t=-d*Math.exp(-n/f);return v.done=!(c<t||t<-c),v.value=v.done?h:h+t,v},flipTarget:function(){}}}var wn={keyframes:bn,spring:C,decay:xn};function On(n){return Sn=n}function An(n){return kn[n].process(qn)}var In=0,Pn="undefined"!=typeof window&&void 0!==window.requestAnimationFrame?function(n){return window.requestAnimationFrame(n)}:function(n){var t=Date.now(),r=Math.max(0,16.7-(t-In));In=t+r,setTimeout(function(){return n(In)},r)},Tn=1/60*1e3,Dn=!0,Sn=!1,jn=!1,qn={delta:0,timestamp:0},Fn=["read","update","preRender","render","postRender"],kn=Fn.reduce(function(n,t){var e,o,u,i,f,a,s,c,p;return n[t]=(e=On,o=[],f=!(u=[]),a=i=0,s=new WeakSet,c=new WeakSet,p={cancel:function(n){var t=u.indexOf(n);s.add(n),-1!==t&&u.splice(t,1)},process:function(n){var t,r;if(f=!0,o=(t=[u,o])[0],(u=t[1]).length=0,i=o.length)for(a=0;a<i;a++)(r=o[a])(n),!0!==c.has(r)||s.has(r)||(p.schedule(r),e(!0));f=!1},schedule:function(n,t,r){void 0===t&&(t=!1),void 0===r&&(r=!1);var e=r&&f,a=e?o:u;s.delete(n),t&&c.add(n),-1===a.indexOf(n)&&(a.push(n),e&&(i=o.length))}}),n},{}),Cn=Fn.reduce(function(n,t){var e=kn[t];return n[t]=function(n,t,r){return void 0===t&&(t=!1),void 0===r&&(r=!1),Sn||En(),e.schedule(n,t,r),n},n},{}),Rn=Fn.reduce(function(n,t){return n[t]=kn[t].cancel,n},{}),Nn=function(n){Sn=!1,qn.delta=Dn?Tn:Math.max(Math.min(n-qn.timestamp,40),1),Dn||(Tn=qn.delta),qn.timestamp=n,jn=!0,Fn.forEach(An),jn=!1,Sn&&(Dn=!1,Pn(Nn))},En=function(){Dn=Sn=!0,jn||Pn(Nn)};function Un(n,t,r){return void 0===r&&(r=0),n-t-r}var zn=function(r){function n(n){var t=n.delta;return r(t)}return{start:function(){return Cn.update(n,!0,!0)},stop:function(){return Rn.update(n)}}};function Wn(n){var t,o,u,i,r=n.from,e=n.autoplay,a=void 0===e||e,f=n.driver,s=void 0===f?zn:f,c=n.elapsed,p=void 0===c?0:c,v=n.repeat,d=void 0===v?0:v,l=n.repeatType,h=void 0===l?"loop":l,m=n.repeatDelay,y=void 0===m?0:m,g=n.onPlay,M=n.onStop,b=n.onComplete,x=n.onRepeat,w=n.onUpdate,O=function(n,t){var r={};for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&t.indexOf(e)<0&&(r[e]=n[e]);if(null!=n&&"function"==typeof Object.getOwnPropertySymbols)for(var a=0,e=Object.getOwnPropertySymbols(n);a<e.length;a++)t.indexOf(e[a])<0&&Object.prototype.propertyIsEnumerable.call(n,e[a])&&(r[e[a]]=n[e[a]]);return r}(n,["from","autoplay","driver","elapsed","repeat","repeatType","repeatDelay","onPlay","onStop","onComplete","onRepeat","onUpdate"]),A=O.to,I=0,P=O.duration,T=!1,D=!0,S=function(n){if(Array.isArray(n.to))return bn;if(wn[n.type])return wn[n.type];var t=new Set(Object.keys(n));return!(t.has("ease")||t.has("duration")&&!t.has("dampingRatio"))&&(t.has("dampingRatio")||t.has("stiffness")||t.has("mass")||t.has("damping")||t.has("restSpeed")||t.has("restDelta"))?C:bn}(O);null!==(t=S.needsInterpolation)&&void 0!==t&&t.call(S,r,A)&&(i=nn([0,100],[r,A],{clamp:!1}),r=0,A=100);var j=S(k(k({},O),{from:r,to:A}));function q(){var n,t,r,e;I++,"reverse"===h?(n=p,t=P,void 0===(r=y)&&(r=0),void 0===(e=D=I%2==0)&&(e=!0),p=e?Un(t+-n,t,r):t-(n-t)+r):(p=Un(p,P,y),"mirror"===h&&j.flipTarget()),T=!1,x&&x()}function F(n){var t,r,e,a;D||(n=-n),p+=n,T||(t=j.next(Math.max(0,p)),u=t.value,i&&(u=i(u)),T=D?t.done:p<=0),null!=w&&w(u),T&&(0===I&&(null!=P||(P=p)),I<d?(r=p,e=P,a=y,(D?e+a<=r:r<=-a)&&q()):(o.stop(),b&&b()))}return a&&(null!=g&&g(),(o=s(F)).start()),{stop:function(){null!=M&&M(),o.stop()}}}function Bn(n,t){return t?n*(1e3/t):0}function $n(n){return 180*n/Math.PI}function _n(n){return n}function Gn(o){return void 0===o&&(o=_n),function(n,t,r){var e=t-r,a=-(0-n+1)*(0-o(Math.abs(e)));return e<=0?t+a:t-a}}function Hn(n){return n*Math.PI/180}function Ln(n){return n.hasOwnProperty("x")&&n.hasOwnProperty("y")}function Vn(n){return Ln(n)&&n.hasOwnProperty("z")}function Jn(n,t){return Math.abs(n-t)}var Kn=Gn(),Qn=Gn(Math.sqrt);function Xn(n,t){return void 0===t&&(t=2),t=Math.pow(10,t),Math.round(n*t)/t}function Yn(n,t,r,e){return void 0===e&&(e=0),Xn(n+r*(t-n)/Math.max(e,r))}function Zn(n,t){return 1-3*t+3*n}function nt(n,t){return 3*t-6*n}var tt=function(n,t,r){return((Zn(t,r)*n+nt(t,r))*n+3*t)*n},rt=function(n,t,r){return 3*Zn(t,r)*n*n+2*nt(t,r)*n+3*t},et=1e-7,at=10;var ot=8;n.angle=function(n,t){return void 0===t&&(t=H),$n(Math.atan2(t.y-n.y,t.x-n.x))},n.animate=Wn,n.anticipate=gn,n.applyOffset=function(t,r){var e=!0;return void 0===r&&(r=t,e=!1),function(n){return e?n-t+r:(t=n,e=!0,r)}},n.attract=Kn,n.attractExpo=Qn,n.backIn=hn,n.backInOut=yn,n.backOut=mn,n.bounceIn=Mn,n.bounceInOut=function(n){return n<.5?.5*(1-sn(1-2*n)):.5*sn(2*n-1)+.5},n.bounceOut=sn,n.circIn=fn,n.circInOut=ln,n.circOut=dn,n.clamp=x,n.createAnticipate=on,n.createAttractor=Gn,n.createBackIn=an,n.createExpoIn=en,n.cubicBezier=function(o,t,u,r){if(o===t&&u===r)return un;for(var i=new Float32Array(11),n=0;n<11;++n)i[n]=tt(.1*n,o,u);function e(n){for(var t=0,r=1;10!==r&&i[r]<=n;++r)t+=.1;var e=t+.1*((n-i[--r])/(i[r+1]-i[r])),a=rt(e,o,u);return.001<=a?function(n,t,r,e){for(var a=0;a<ot;++a){var o=rt(t,r,e);if(0===o)return t;t-=(tt(t,r,e)-n)/o}return t}(n,e,o,u):0===a?e:function(n,t,r,e,a){for(var o,u,i=0;0<(o=tt(u=t+(r-t)/2,e,a)-n)?r=u:t=u,Math.abs(o)>et&&++i<at;);return u}(n,t,t+.1,o,u)}return function(n){return 0===n||1===n?n:tt(e(n),t,r)}},n.decay=xn,n.degreesToRadians=Hn,n.distance=function(n,t){if(F(n)&&F(t))return Jn(n,t);if(Ln(n)&&Ln(t)){var r=Jn(n.x,t.x),e=Jn(n.y,t.y),a=Vn(n)&&Vn(t)?Jn(n.z,t.z):0;return Math.sqrt(Math.pow(r,2)+Math.pow(e,2)+Math.pow(a,2))}},n.easeIn=cn,n.easeInOut=vn,n.easeOut=pn,n.inertia=function(n){var t,r,e,a,o,u,i=n.from,f=void 0===i?0:i,s=n.velocity,c=void 0===s?0:s,p=n.min,v=n.max,d=n.power,l=void 0===d?.8:d,h=n.timeConstant,m=void 0===h?750:h,y=n.bounceStiffness,g=void 0===y?500:y,M=n.bounceDamping,b=void 0===M?10:M,x=n.restDelta,w=void 0===x?1:x,O=n.modifyTarget,A=n.driver,I=n.onUpdate,P=n.onComplete;function T(n){return void 0!==p&&n<p||void 0!==v&&v<n}function D(n){return void 0!==p&&(void 0===v||Math.abs(p-n)<Math.abs(v-n))?p:v}function S(r){null!=t&&t.stop(),t=Wn(k(k({},r),{driver:A,onUpdate:function(n){var t;null!=I&&I(n),null!==(t=r.onUpdate)&&void 0!==t&&t.call(r,n)},onComplete:P}))}function j(n){S(k({type:"spring",stiffness:g,damping:b,restDelta:w},n))}return T(f)?j({from:f,velocity:c,to:D(f)}):(r=l*c+f,void 0!==O&&(r=O(r)),e=D(r),a=e===p?-1:1,S({type:"decay",from:f,velocity:c,timeConstant:m,power:l,restDelta:w,modifyTarget:O,onUpdate:T(r)?function(n){o=u,c=Bn((u=n)-o,qn.delta),(1==a&&e<n||-1==a&&n<e)&&j({from:n,to:e,velocity:c})}:void 0})),{stop:function(){return null==t?void 0:t.stop()}}},n.interpolate=nn,n.isPoint=Ln,n.isPoint3D=Vn,n.keyframes=bn,n.linear=un,n.mirrorEasing=rn,n.mix=f,n.mixColor=G,n.mixComplex=X,n.pipe=L,n.pointFromVector=function(n,t,r){return t=Hn(t),{x:r*Math.cos(t)+n.x,y:r*Math.sin(t)+n.y}},n.progress=w,n.radiansToDegrees=$n,n.reverseEasing=tn,n.smooth=function(a){void 0===a&&(a=50);var o=0,u=0;return function(n){var t=qn.timestamp,r=t!==u?t-u:0,e=r?Yn(o,n,r,a):o;return u=t,o=e}},n.smoothFrame=Yn,n.snap=function(a){if("number"==typeof a)return function(n){return Math.round(n/a)*a};var o=0,u=a.length;return function(n){var t=Math.abs(a[0]-n);for(o=1;o<u;o++){var r=a[o],e=Math.abs(r-n);if(0===e)return r;if(t<e)return a[o-1];if(o===u-1)return r;t=e}}},n.spring=C,n.steps=function(e,a){return void 0===a&&(a="end"),function(n){var t=(n="end"===a?Math.min(n,.999):Math.max(n,.001))*e,r="end"===a?Math.floor(t):Math.ceil(t);return x(0,1,r/e)}},n.toDecimal=Xn,n.velocityPerFrame=function(n,t){return n/(1e3/t)},n.velocityPerSecond=Bn,n.wrap=function(n,t,r){var e=t-n;return((r-n)%e+e)%e+n},Object.defineProperty(n,"__esModule",{value:!0})}); | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t=t||self).popmotion={})}(this,function(t){"use strict";var q=function(){return(q=Object.assign||function(t){for(var n,r=1,e=arguments.length;r<e;r++)for(var a in n=arguments[r])Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a]);return t}).apply(this,arguments)};function k(t,n){var r={};for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&n.indexOf(e)<0&&(r[e]=t[e]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols)for(var a=0,e=Object.getOwnPropertySymbols(t);a<e.length;a++)n.indexOf(e[a])<0&&Object.prototype.propertyIsEnumerable.call(t,e[a])&&(r[e[a]]=t[e[a]]);return r}var b=function(){},x=function(t,n,r){return Math.min(Math.max(r,t),n)},l=.001,h=.01,m=10,y=.05,g=1;function w(t){var u,n=t.duration,i=void 0===n?800:n,r=t.bounce,e=void 0===r?.25:r,a=t.velocity,f=void 0===a?0:a,o=t.mass,s=void 0===o?1:o,c=x(y,g,c=1-e),i=x(h,m,i/1e3),p=c<1?(u=function(t){var n=t*c,r=n*i,e=n-f,a=O(t,c),o=Math.exp(-r);return l-e/a*o},function(t){var n=t*c*i,r=n*f+f,e=Math.pow(c,2)*Math.pow(t,2)*i,a=Math.exp(-n),o=O(Math.pow(t,2),c);return(r-e)*a*(0<-u(t)+l?-1:1)/o}):(u=function(t){return Math.exp(-t*i)*((t-f)*i+1)-l},function(t){return Math.exp(-t*i)*(i*i*(f-t))}),v=function(t,n,r){for(var e=r,a=1;a<M;a++)e-=t(e)/n(e);return e}(u,p,5/i);if(isNaN(v))return{stiffness:100,damping:10};var d=Math.pow(v,2)*s;return{stiffness:d,damping:2*c*Math.sqrt(s*d)}}var M=12;function O(t,n){return t*Math.sqrt(1-n*n)}var A=["duration","bounce"],I=["stiffness","damping","mass"];function D(n,t){return t.some(function(t){return void 0!==n[t]})}function C(t){var n,r,e,a=t.from,f=void 0===a?0:a,o=t.to,s=void 0===o?1:o,u=t.restSpeed,i=void 0===u?2:u,c=t.restDelta,p=k(t,["from","to","restSpeed","restDelta"]),v={done:!1,value:f},d=(e=q({velocity:0,stiffness:100,damping:10,mass:1,isResolvedFromDuration:!1},n=p),!D(n,I)&&D(n,A)&&(r=w(n),(e=q(q(q({},e),r),{velocity:0,mass:1})).isResolvedFromDuration=!0),e),l=d.stiffness,h=d.damping,m=d.mass,y=d.velocity,g=d.isResolvedFromDuration,M=P,b=P;function x(){var r,e,a=y?-y/1e3:0,o=s-f,u=h/(2*Math.sqrt(l*m)),i=Math.sqrt(l/m)/1e3;null!=c||(c=Math.abs(s-f)<=1?.01:.4),u<1?(r=O(i,u),M=function(t){var n=Math.exp(-u*i*t);return s-n*((a+u*i*o)/r*Math.sin(r*t)+o*Math.cos(r*t))},b=function(t){var n=Math.exp(-u*i*t);return u*i*n*(Math.sin(r*t)*(a+u*i*o)/r+o*Math.cos(r*t))-n*(Math.cos(r*t)*(a+u*i*o)-r*o*Math.sin(r*t))}):M=1==u?function(t){return s-Math.exp(-i*t)*(o+(a+i*o)*t)}:(e=i*Math.sqrt(u*u-1),function(t){var n=Math.exp(-u*i*t),r=Math.min(e*t,300);return s-n*((a+u*i*o)*Math.sinh(r)+e*o*Math.cosh(r))/e})}return x(),{next:function(t){var n,r,e,a=M(t);return g?v.done=t>=p.duration:(n=1e3*b(t),r=Math.abs(n)<=i,e=Math.abs(s-a)<=c,v.done=r&&e),v.value=v.done?s:a,v},flipTarget:function(){var t;y=-y,f=(t=[s,f])[0],s=t[1],x()}}}C.needsInterpolation=function(t,n){return"string"==typeof t||"string"==typeof n};function f(t,n,r){return-r*t+r*n+t}function n(n,r){return function(t){return Math.max(Math.min(t,r),n)}}function p(t){return t%1?Number(t.toFixed(5)):t}function r(t){return void 0!==t.red}function e(t){return void 0!==t.hue}var a,P=function(t){return 0},T=function(t,n,r){var e=n-t;return 0==e?1:(r-t)/e},s=/(-)?(\d[\d\.]*)/g,c=/(#[0-9a-f]{6}|#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))/gi,o=/^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))$/i,u={test:function(t){return"number"==typeof t},parse:parseFloat,transform:function(t){return t}},v=q(q({},u),{transform:n(0,1)}),d=(q(q({},u),{default:1}),a="%",{test:function(t){return"string"==typeof t&&t.endsWith(a)&&1===t.split(" ").length},parse:parseFloat,transform:function(t){return""+t+a}}),i=(q(q({},d),{parse:function(t){return d.parse(t)/100},transform:function(t){return d.transform(100*t)}}),n(0,255));function F(o){return function(t){if("string"!=typeof t)return t;for(var n,r={},e=(n=t).substring(n.indexOf("(")+1,n.lastIndexOf(")")).replace(/(,|\/)/g," ").split(/ \s*/),a=0;a<4;a++)r[o[a]]=void 0!==e[a]?parseFloat(e[a]):1;return r}}var S=q(q({},u),{transform:function(t){return Math.round(i(t))}});function R(t,n){return t.startsWith(n)&&o.test(t)}function j(t){return"number"==typeof t?0:t}function N(t,n,r){var e=t*t,a=n*n;return Math.sqrt(Math.max(0,r*(a-e)+e))}function E(n){return V.find(function(t){return t.test(n)})}function U(t){return"number"==typeof t}function z(n,r){return function(t){return r(n(t))}}var W={test:function(t){return"string"==typeof t?R(t,"rgb"):r(t)},parse:F(["red","green","blue","alpha"]),transform:function(t){var n,r,e,a,o,u=t.red,i=t.green,f=t.blue,s=t.alpha,c=void 0===s?1:s;return n={red:S.transform(u),green:S.transform(i),blue:S.transform(f),alpha:p(v.transform(c))},r=n.red,e=n.green,a=n.blue,o=n.alpha,"rgba("+r+", "+e+", "+a+", "+(void 0===o?1:o)+")"}},B={test:function(t){return"string"==typeof t?R(t,"hsl"):e(t)},parse:F(["hue","saturation","lightness","alpha"]),transform:function(t){var n,r,e,a,o,u=t.hue,i=t.saturation,f=t.lightness,s=t.alpha,c=void 0===s?1:s;return n={hue:Math.round(u),saturation:d.transform(p(i)),lightness:d.transform(p(f)),alpha:p(v.transform(c))},r=n.hue,e=n.saturation,a=n.lightness,o=n.alpha,"hsla("+r+", "+e+", "+a+", "+(void 0===o?1:o)+")"}},$=q(q({},W),{test:function(t){return"string"==typeof t&&R(t,"#")},parse:function(t){var n="",r="",e="";return 4<t.length?(n=t.substr(1,2),r=t.substr(3,2),e=t.substr(5,2)):(n=t.substr(1,1),r=t.substr(2,1),e=t.substr(3,1),n+=n,r+=r,e+=e),{red:parseInt(n,16),green:parseInt(r,16),blue:parseInt(e,16),alpha:1}}}),_={test:function(t){return"string"==typeof t&&o.test(t)||r(t)||e(t)},parse:function(t){return W.test(t)?W.parse(t):B.test(t)?B.parse(t):$.test(t)?$.parse(t):t},transform:function(t){return r(t)?W.transform(t):e(t)?B.transform(t):t}},G="${c}",H="${n}",L={test:function(t){if("string"!=typeof t||!isNaN(t))return!1;var n=0,r=t.match(s),e=t.match(c);return r&&(n+=r.length),e&&(n+=e.length),0<n},parse:function(t){var n=t,r=[],e=n.match(c);e&&(n=n.replace(c,G),r.push.apply(r,e.map(_.parse)));var a=n.match(s);return a&&r.push.apply(r,a.map(u.parse)),r},createTransformer:function(t){var e=t,a=0,n=t.match(c),o=n?n.length:0;if(n)for(var r=0;r<o;r++)e=e.replace(n[r],G),a++;var u=e.match(s),i=u?u.length:0;if(u)for(r=0;r<i;r++)e=e.replace(u[r],H),a++;return function(t){for(var n=e,r=0;r<a;r++)n=n.replace(r<o?G:H,r<o?_.transform(t[r]):p(t[r]));return n}},getAnimatableNone:function(t){var n=L.parse(t);return L.createTransformer(t)(n.map(j))}},V=[$,W,B],J=function(t,n){var r=E(t),e=E(n);b(r.transform===e.transform);var a=r.parse(t),o=e.parse(n),u=q({},a),i=r===B?f:N;return function(t){for(var n in u)"alpha"!==n&&(u[n]=i(a[n],o[n],t));return u.alpha=f(a.alpha,o.alpha,t),r.transform(u)}},K={x:0,y:0,z:0},Q=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return t.reduce(z)};function X(n,r){return U(n)?function(t){return f(n,r,t)}:(_.test(n)?J:nt)(n,r)}var Y=function(t,r){var e=function(){for(var t=0,n=0,r=arguments.length;n<r;n++)t+=arguments[n].length;for(var e=Array(t),a=0,n=0;n<r;n++)for(var o=arguments[n],u=0,i=o.length;u<i;u++,a++)e[a]=o[u];return e}(t),a=e.length,o=t.map(function(t,n){return X(t,r[n])});return function(t){for(var n=0;n<a;n++)e[n]=o[n](t);return e}},Z=function(t,n){var r=q(q({},t),n),e={};for(var a in r)void 0!==t[a]&&void 0!==n[a]&&(e[a]=X(t[a],n[a]));return function(t){for(var n in e)r[n]=e[n](t);return r}};function tt(t){for(var n=L.parse(t),r=n.length,e=0,a=0,o=0,u=0;u<r;u++)e||"number"==typeof n[u]?e++:void 0!==n[u].hue?o++:a++;return{parsed:n,numNumbers:e,numRGB:a,numHSL:o}}var nt=function(t,n){var r=L.createTransformer(n),e=tt(t),a=tt(n);return Q(Y(e.parsed,a.parsed),r)},rt=function(n,r){return function(t){return f(n,r,t)}};function et(t,n,r){for(var e,a=[],o=r||("number"==typeof(e=t[0])?rt:"string"==typeof e?_.test(e)?J:nt:Array.isArray(e)?Y:"object"==typeof e?Z:void 0),u=t.length-1,i=0;i<u;i++){var f,s=o(t[i],t[i+1]);n&&(f=Array.isArray(n)?n[i]:n,s=Q(f,s)),a.push(s)}return a}function at(n,t,r){var e=void 0===r?{}:r,a=e.clamp,o=void 0===a||a,u=e.ease,i=e.mixer,f=n.length;b(f===t.length),b(!u||!Array.isArray(u)||u.length===f-1),n[0]>n[f-1]&&(n=[].concat(n),t=[].concat(t),n.reverse(),t.reverse());var s,c,p,v,d,l,h,m,y,g=et(t,u,i),M=2===f?(l=g,h=(d=n)[0],m=d[1],y=l[0],function(t){return y(T(h,m,t))}):(c=g,p=(s=n).length,v=p-1,function(t){var n=0,r=!1;if(t<=s[0]?r=!0:t>=s[v]&&(n=v-1,r=!0),!r){for(var e=1;e<p&&!(s[e]>t||e===v);e++);n=e-1}var a=T(s[n],s[n+1],t);return c[n](a)});return o?function(t){return M(x(n[0],n[f-1],t))}:M}function ot(n){return function(t){return 1-n(1-t)}}function ut(n){return function(t){return t<=.5?n(2*t)/2:(2-n(2*(1-t)))/2}}function it(n){return function(t){return Math.pow(t,n)}}function ft(n){return function(t){return t*t*((n+1)*t-n)}}function st(t){var n=ft(t);return function(t){return(t*=2)<1?.5*n(t):.5*(2-Math.pow(2,-10*(t-1)))}}function ct(t){return t}function pt(t){return 1-Math.sin(Math.acos(t))}function vt(t){if(1===t||0===t)return t;var n=t*t;return t<4/11?7.5625*n:t<8/11?9.075*n-9.9*t+3.4:t<.9?4356/361*n-35442/1805*t+16061/1805:10.8*t*t-20.52*t+10.72}var dt=it(2),lt=ot(dt),ht=ut(dt),mt=ot(pt),yt=ut(mt),gt=ft(1.525),Mt=ot(gt),bt=ut(gt),xt=st(1.525),wt=ot(vt);function Ot(t){var n,r,e,a,o=t.from,u=void 0===o?0:o,i=t.to,f=void 0===i?1:i,s=t.ease,c=t.offset,p=t.duration,v=void 0===p?300:p,d={done:!1,value:u},l=Array.isArray(f)?f:[u,f],h=(n=null!=c?c:(a=(e=l).length,e.map(function(t,n){return 0!==n?n/(a-1):0})),r=v,n.map(function(t){return t*r}));function m(){return at(h,l,{ease:Array.isArray(s)?s:(n=s,(t=l).map(function(){return n||ht}).splice(0,t.length-1))});var t,n}var y=m();return{next:function(t){return d.value=y(t),d.done=v<=t,d},flipTarget:function(){l.reverse(),y=m()}}}function At(t){var n=t.velocity,r=void 0===n?0:n,e=t.from,a=void 0===e?0:e,o=t.power,u=void 0===o?.8:o,i=t.timeConstant,f=void 0===i?350:i,s=t.restDelta,c=void 0===s?.5:s,p=t.modifyTarget,v={done:!1,value:a},d=u*r,l=a+d,h=void 0===p?l:p(l);return h!==l&&(d=h-a),{next:function(t){var n=-d*Math.exp(-t/f);return v.done=!(c<n||n<-c),v.value=v.done?h:h+n,v},flipTarget:function(){}}}var It={keyframes:Ot,spring:C,decay:At};function Dt(t){return jt=t}function Pt(t){return Nt[t].process(kt)}var Tt=0,Ft="undefined"!=typeof window&&void 0!==window.requestAnimationFrame?function(t){return window.requestAnimationFrame(t)}:function(t){var n=Date.now(),r=Math.max(0,16.7-(n-Tt));Tt=n+r,setTimeout(function(){return t(Tt)},r)},St=1/60*1e3,Rt=!0,jt=!1,qt=!1,kt={delta:0,timestamp:0},Ct=["read","update","preRender","render","postRender"],Nt=Ct.reduce(function(t,n){var e,o,u,i,f,a,s,c,p;return t[n]=(e=Dt,o=[],f=!(u=[]),a=i=0,s=new WeakSet,c=new WeakSet,p={cancel:function(t){var n=u.indexOf(t);s.add(t),-1!==n&&u.splice(n,1)},process:function(t){var n,r;if(f=!0,o=(n=[u,o])[0],(u=n[1]).length=0,i=o.length)for(a=0;a<i;a++)(r=o[a])(t),!0!==c.has(r)||s.has(r)||(p.schedule(r),e(!0));f=!1},schedule:function(t,n,r){void 0===n&&(n=!1),void 0===r&&(r=!1);var e=r&&f,a=e?o:u;s.delete(t),n&&c.add(t),-1===a.indexOf(t)&&(a.push(t),e&&(i=o.length))}}),t},{}),Et=Ct.reduce(function(t,n){var e=Nt[n];return t[n]=function(t,n,r){return void 0===n&&(n=!1),void 0===r&&(r=!1),jt||Wt(),e.schedule(t,n,r),t},t},{}),Ut=Ct.reduce(function(t,n){return t[n]=Nt[n].cancel,t},{}),zt=function(t){jt=!1,kt.delta=Rt?St:Math.max(Math.min(t-kt.timestamp,40),1),Rt||(St=kt.delta),kt.timestamp=t,qt=!0,Ct.forEach(Pt),qt=!1,jt&&(Rt=!1,Ft(zt))},Wt=function(){Rt=jt=!0,qt||Ft(zt)};function Bt(t,n,r){return void 0===r&&(r=0),t-n-r}var $t=function(r){function t(t){var n=t.delta;return r(n)}return{start:function(){return Et.update(t,!0,!0)},stop:function(){return Ut.update(t)}}};function _t(t){var n,o,u,i,r=t.from,e=t.autoplay,a=void 0===e||e,f=t.driver,s=void 0===f?$t:f,c=t.elapsed,p=void 0===c?0:c,v=t.repeat,d=void 0===v?0:v,l=t.repeatType,h=void 0===l?"loop":l,m=t.repeatDelay,y=void 0===m?0:m,g=t.onPlay,M=t.onStop,b=t.onComplete,x=t.onRepeat,w=t.onUpdate,O=k(t,["from","autoplay","driver","elapsed","repeat","repeatType","repeatDelay","onPlay","onStop","onComplete","onRepeat","onUpdate"]),A=O.to,I=0,D=O.duration,P=!1,T=!0,F=function(t){if(Array.isArray(t.to))return Ot;if(It[t.type])return It[t.type];var n=new Set(Object.keys(t));return!(n.has("ease")||n.has("duration")&&!n.has("dampingRatio"))&&(n.has("dampingRatio")||n.has("stiffness")||n.has("mass")||n.has("damping")||n.has("restSpeed")||n.has("restDelta"))?C:Ot}(O);null!==(n=F.needsInterpolation)&&void 0!==n&&n.call(F,r,A)&&(i=at([0,100],[r,A],{clamp:!1}),r=0,A=100);var S=F(q(q({},O),{from:r,to:A}));function R(){var t,n,r,e;I++,"reverse"===h?(t=p,n=D,void 0===(r=y)&&(r=0),void 0===(e=T=I%2==0)&&(e=!0),p=e?Bt(n+-t,n,r):n-(t-n)+r):(p=Bt(p,D,y),"mirror"===h&&S.flipTarget()),P=!1,x&&x()}function j(t){var n,r,e,a;T||(t=-t),p+=t,P||(n=S.next(Math.max(0,p)),u=n.value,i&&(u=i(u)),P=T?n.done:p<=0),null!=w&&w(u),P&&(0===I&&(null!=D||(D=p)),I<d?(r=p,e=D,a=y,(T?e+a<=r:r<=-a)&&R()):(o.stop(),b&&b()))}return a&&(null!=g&&g(),(o=s(j)).start()),{stop:function(){null!=M&&M(),o.stop()}}}function Gt(t,n){return n?t*(1e3/n):0}function Ht(t){return 180*t/Math.PI}function Lt(t){return t}function Vt(o){return void 0===o&&(o=Lt),function(t,n,r){var e=n-r,a=-(0-t+1)*(0-o(Math.abs(e)));return e<=0?n+a:n-a}}function Jt(t){return t*Math.PI/180}function Kt(t){return t.hasOwnProperty("x")&&t.hasOwnProperty("y")}function Qt(t){return Kt(t)&&t.hasOwnProperty("z")}function Xt(t,n){return Math.abs(t-n)}var Yt=Vt(),Zt=Vt(Math.sqrt);function tn(t,n){return void 0===n&&(n=2),n=Math.pow(10,n),Math.round(t*n)/n}function nn(t,n,r,e){return void 0===e&&(e=0),tn(t+r*(n-t)/Math.max(e,r))}function rn(t,n){return 1-3*n+3*t}function en(t,n){return 3*n-6*t}var an=function(t,n,r){return((rn(n,r)*t+en(n,r))*t+3*n)*t},on=function(t,n,r){return 3*rn(n,r)*t*t+2*en(n,r)*t+3*n},un=1e-7,fn=10;var sn=8;t.angle=function(t,n){return void 0===n&&(n=K),Ht(Math.atan2(n.y-t.y,n.x-t.x))},t.animate=_t,t.anticipate=xt,t.applyOffset=function(n,r){var e=!0;return void 0===r&&(r=n,e=!1),function(t){return e?t-n+r:(n=t,e=!0,r)}},t.attract=Yt,t.attractExpo=Zt,t.backIn=gt,t.backInOut=bt,t.backOut=Mt,t.bounceIn=wt,t.bounceInOut=function(t){return t<.5?.5*(1-vt(1-2*t)):.5*vt(2*t-1)+.5},t.bounceOut=vt,t.circIn=pt,t.circInOut=yt,t.circOut=mt,t.clamp=x,t.createAnticipate=st,t.createAttractor=Vt,t.createBackIn=ft,t.createExpoIn=it,t.cubicBezier=function(o,n,u,r){if(o===n&&u===r)return ct;for(var i=new Float32Array(11),t=0;t<11;++t)i[t]=an(.1*t,o,u);function e(t){for(var n=0,r=1;10!==r&&i[r]<=t;++r)n+=.1;var e=n+.1*((t-i[--r])/(i[r+1]-i[r])),a=on(e,o,u);return.001<=a?function(t,n,r,e){for(var a=0;a<sn;++a){var o=on(n,r,e);if(0===o)return n;n-=(an(n,r,e)-t)/o}return n}(t,e,o,u):0===a?e:function(t,n,r,e,a){for(var o,u,i=0;0<(o=an(u=n+(r-n)/2,e,a)-t)?r=u:n=u,Math.abs(o)>un&&++i<fn;);return u}(t,n,n+.1,o,u)}return function(t){return 0===t||1===t?t:an(e(t),n,r)}},t.decay=At,t.degreesToRadians=Jt,t.distance=function(t,n){if(U(t)&&U(n))return Xt(t,n);if(Kt(t)&&Kt(n)){var r=Xt(t.x,n.x),e=Xt(t.y,n.y),a=Qt(t)&&Qt(n)?Xt(t.z,n.z):0;return Math.sqrt(Math.pow(r,2)+Math.pow(e,2)+Math.pow(a,2))}},t.easeIn=dt,t.easeInOut=ht,t.easeOut=lt,t.inertia=function(t){var n,r,e,a,o,u,i=t.from,f=void 0===i?0:i,s=t.velocity,c=void 0===s?0:s,p=t.min,v=t.max,d=t.power,l=void 0===d?.8:d,h=t.timeConstant,m=void 0===h?750:h,y=t.bounceStiffness,g=void 0===y?500:y,M=t.bounceDamping,b=void 0===M?10:M,x=t.restDelta,w=void 0===x?1:x,O=t.modifyTarget,A=t.driver,I=t.onUpdate,D=t.onComplete;function P(t){return void 0!==p&&t<p||void 0!==v&&v<t}function T(t){return void 0!==p&&(void 0===v||Math.abs(p-t)<Math.abs(v-t))?p:v}function F(r){null!=n&&n.stop(),n=_t(q(q({},r),{driver:A,onUpdate:function(t){var n;null!=I&&I(t),null!==(n=r.onUpdate)&&void 0!==n&&n.call(r,t)},onComplete:D}))}function S(t){F(q({type:"spring",stiffness:g,damping:b,restDelta:w},t))}return P(f)?S({from:f,velocity:c,to:T(f)}):(r=l*c+f,void 0!==O&&(r=O(r)),e=T(r),a=e===p?-1:1,F({type:"decay",from:f,velocity:c,timeConstant:m,power:l,restDelta:w,modifyTarget:O,onUpdate:P(r)?function(t){o=u,c=Gt((u=t)-o,kt.delta),(1==a&&e<t||-1==a&&t<e)&&S({from:t,to:e,velocity:c})}:void 0})),{stop:function(){return null==n?void 0:n.stop()}}},t.interpolate=at,t.isPoint=Kt,t.isPoint3D=Qt,t.keyframes=Ot,t.linear=ct,t.mirrorEasing=ut,t.mix=f,t.mixColor=J,t.mixComplex=nt,t.pipe=Q,t.pointFromVector=function(t,n,r){return n=Jt(n),{x:r*Math.cos(n)+t.x,y:r*Math.sin(n)+t.y}},t.progress=T,t.radiansToDegrees=Ht,t.reverseEasing=ot,t.smooth=function(a){void 0===a&&(a=50);var o=0,u=0;return function(t){var n=kt.timestamp,r=n!==u?n-u:0,e=r?nn(o,t,r,a):o;return u=n,o=e}},t.smoothFrame=nn,t.snap=function(a){if("number"==typeof a)return function(t){return Math.round(t/a)*a};var o=0,u=a.length;return function(t){var n=Math.abs(a[0]-t);for(o=1;o<u;o++){var r=a[o],e=Math.abs(r-t);if(0===e)return r;if(n<e)return a[o-1];if(o===u-1)return r;n=e}}},t.spring=C,t.steps=function(e,a){return void 0===a&&(a="end"),function(t){var n=(t="end"===a?Math.min(t,.999):Math.max(t,.001))*e,r="end"===a?Math.floor(n):Math.ceil(n);return x(0,1,r/e)}},t.toDecimal=tn,t.velocityPerFrame=function(t,n){return t/(1e3/n)},t.velocityPerSecond=Gt,t.wrap=function(t,n,r){var e=n-t;return((r-t)%e+e)%e+t},Object.defineProperty(t,"__esModule",{value:!0})}); |
import { SpringOptions, Animation } from "../types"; | ||
export declare function spring({ from, to, velocity, stiffness, damping, mass, restSpeed, restDelta, duration, bounce, }: SpringOptions): Animation<number>; | ||
export declare function spring({ from, to, restSpeed, restDelta, ...options }: SpringOptions): Animation<number>; | ||
export declare namespace spring { | ||
var needsInterpolation: (a: any, b: any) => boolean; | ||
} |
@@ -53,11 +53,13 @@ import { Easing } from "../easing/types"; | ||
} | ||
export interface SpringOptions { | ||
from?: number; | ||
to?: number; | ||
export interface PhysicsSpringOptions { | ||
velocity?: number; | ||
stiffness?: number; | ||
damping?: number; | ||
mass?: number; | ||
} | ||
export interface SpringOptions extends PhysicsSpringOptions { | ||
from?: number; | ||
to?: number; | ||
duration?: number; | ||
bounce?: number; | ||
mass?: number; | ||
restSpeed?: number; | ||
@@ -64,0 +66,0 @@ restDelta?: number; |
@@ -90,14 +90,21 @@ 'use strict'; | ||
var durationKeys = ["duration", "bounce"]; | ||
var physicsKeys = ["stiffness", "damping", "mass"]; | ||
function isSpringType(options, keys) { | ||
return keys.some(function (key) { return options[key] !== undefined; }); | ||
} | ||
function getSpringOptions(options) { | ||
var springOptions = tslib.__assign({ velocity: 0.0, stiffness: 100, damping: 10, mass: 1.0, isResolvedFromDuration: false }, options); | ||
if (!isSpringType(options, physicsKeys) && | ||
isSpringType(options, durationKeys)) { | ||
var derived = findSpring(options); | ||
springOptions = tslib.__assign(tslib.__assign(tslib.__assign({}, springOptions), derived), { velocity: 0.0, mass: 1.0 }); | ||
springOptions.isResolvedFromDuration = true; | ||
} | ||
return springOptions; | ||
} | ||
function spring(_a) { | ||
var _b = _a.from, from = _b === void 0 ? 0.0 : _b, _c = _a.to, to = _c === void 0 ? 1.0 : _c, _d = _a.velocity, velocity = _d === void 0 ? 0.0 : _d, _e = _a.stiffness, stiffness = _e === void 0 ? 100 : _e, _f = _a.damping, damping = _f === void 0 ? 10 : _f, _g = _a.mass, mass = _g === void 0 ? 1.0 : _g, _h = _a.restSpeed, restSpeed = _h === void 0 ? 2 : _h, restDelta = _a.restDelta, duration = _a.duration, bounce = _a.bounce; | ||
var isResolvedFromDuration = false; | ||
var _b = _a.from, from = _b === void 0 ? 0.0 : _b, _c = _a.to, to = _c === void 0 ? 1.0 : _c, _d = _a.restSpeed, restSpeed = _d === void 0 ? 2 : _d, restDelta = _a.restDelta, options = tslib.__rest(_a, ["from", "to", "restSpeed", "restDelta"]); | ||
var state = { done: false, value: from }; | ||
if (duration !== undefined || bounce !== undefined) { | ||
isResolvedFromDuration = true; | ||
var derived = findSpring({ duration: duration, bounce: bounce }); | ||
stiffness = derived.stiffness; | ||
damping = derived.damping; | ||
velocity = 0.0; | ||
mass = 1.0; | ||
} | ||
var _e = getSpringOptions(options), stiffness = _e.stiffness, damping = _e.damping, mass = _e.mass, velocity = _e.velocity, isResolvedFromDuration = _e.isResolvedFromDuration; | ||
var resolveSpring = zero; | ||
@@ -184,3 +191,3 @@ var resolveVelocity = zero; | ||
else { | ||
state.done = t >= duration; | ||
state.done = t >= options.duration; | ||
} | ||
@@ -187,0 +194,0 @@ state.value = state.done ? to : current; |
{ | ||
"name": "popmotion", | ||
"version": "9.0.0-rc.19", | ||
"version": "9.0.0-rc.20", | ||
"description": "The animator's toolbox", | ||
@@ -5,0 +5,0 @@ "author": "Matt Perry", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4163
253817