@popmotion/popcorn
Advanced tools
Comparing version 0.3.1 to 0.3.2
@@ -5,2 +5,12 @@ # Changelog | ||
## [0.3.2] 2019-03-12 | ||
### Fixing | ||
- Converting `interpolate` to generic types. | ||
### Upgrading | ||
- Upgrading `style-value-types@3.1.0`. | ||
## [0.3.1] 2018-11-28 | ||
@@ -7,0 +17,0 @@ |
@@ -228,10 +228,10 @@ import { hsla, rgba, hex, color, complex } from 'style-value-types'; | ||
}; | ||
var interpolate = (function (input, output, _a) { | ||
function interpolate(input, output, _a) { | ||
var _b = _a === void 0 ? {} : _a, _c = _b.clamp, clamp = _c === void 0 ? true : _c, ease = _b.ease; | ||
var inputLength = input.length; | ||
invariant(inputLength === output.length, 'Both input and output ranges must be the same length'); | ||
invariant(!ease || !Array.isArray(ease) || ease.length === input.length - 1, 'Array of easing functions must be of length `input.length - 1`, as it applies to the transitions **between** the defined values.'); | ||
invariant(!ease || !Array.isArray(ease) || ease.length === inputLength - 1, 'Array of easing functions must be of length `input.length - 1`, as it applies to the transitions **between** the defined values.'); | ||
if (input[0] > input[inputLength - 1]) { | ||
input = input.slice(); | ||
output = output.slice(); | ||
input = [].concat(input); | ||
output = [].concat(output); | ||
input.reverse(); | ||
@@ -241,9 +241,9 @@ output.reverse(); | ||
var mixers = createMixers(output, ease); | ||
var interpolate = inputLength === 2 | ||
var interpolator = inputLength === 2 | ||
? fastInterpolate(input, mixers) | ||
: slowInterpolate(input, mixers); | ||
return clamp | ||
? pipe(clamp$1(input[0], input[inputLength - 1]), interpolate) | ||
: interpolate; | ||
}); | ||
? pipe(clamp$1(input[0], input[inputLength - 1]), interpolator) | ||
: interpolator; | ||
} | ||
@@ -250,0 +250,0 @@ var pointFromVector = (function (origin, angle, distance) { |
@@ -166,2 +166,3 @@ (function (global, factory) { | ||
var percent = createUnitType('%'); | ||
var progressPercentage = __assign$1({}, percent, { parse: function (v) { return percent.parse(v) / 100; }, transform: function (v) { return percent.transform(v * 100); } }); | ||
@@ -465,10 +466,10 @@ var clampRgbUnit = clamp$2(0, 255); | ||
}; | ||
var interpolate = (function (input, output, _a) { | ||
function interpolate(input, output, _a) { | ||
var _b = _a === void 0 ? {} : _a, _c = _b.clamp, clamp = _c === void 0 ? true : _c, ease = _b.ease; | ||
var inputLength = input.length; | ||
invariant(inputLength === output.length, 'Both input and output ranges must be the same length'); | ||
invariant(!ease || !Array.isArray(ease) || ease.length === input.length - 1, 'Array of easing functions must be of length `input.length - 1`, as it applies to the transitions **between** the defined values.'); | ||
invariant(!ease || !Array.isArray(ease) || ease.length === inputLength - 1, 'Array of easing functions must be of length `input.length - 1`, as it applies to the transitions **between** the defined values.'); | ||
if (input[0] > input[inputLength - 1]) { | ||
input = input.slice(); | ||
output = output.slice(); | ||
input = [].concat(input); | ||
output = [].concat(output); | ||
input.reverse(); | ||
@@ -478,9 +479,9 @@ output.reverse(); | ||
var mixers = createMixers(output, ease); | ||
var interpolate = inputLength === 2 | ||
var interpolator = inputLength === 2 | ||
? fastInterpolate(input, mixers) | ||
: slowInterpolate(input, mixers); | ||
return clamp | ||
? pipe(clamp$1(input[0], input[inputLength - 1]), interpolate) | ||
: interpolate; | ||
}); | ||
? pipe(clamp$1(input[0], input[inputLength - 1]), interpolator) | ||
: interpolator; | ||
} | ||
@@ -556,5 +557,8 @@ var pointFromVector = (function (origin, angle, distance) { | ||
schedule: function (process, keepAlive, immediate) { | ||
if (keepAlive === void 0) { keepAlive = false; } | ||
if (immediate === void 0) { immediate = false; } | ||
invariant(typeof process === 'function', 'Argument must be a function'); | ||
var addToCurrentBuffer = immediate && isProcessing; | ||
var buffer = addToCurrentBuffer ? processToRun : processToRunNextFrame; | ||
cancelled.delete(process); | ||
if (keepAlive) | ||
@@ -561,0 +565,0 @@ toKeepAlive.add(process); |
@@ -1,1 +0,1 @@ | ||
!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r(n.popcorn={})}(this,function(n){"use strict";var r,t={x:0,y:0,z:0},e=function(n){return"number"==typeof n},u=function(n){return 180*n/Math.PI},a=function(n){return function(r,t,e){return void 0!==e?n(r,t,e):function(e){return n(r,t,e)}}},o=a(function(n,r,t){return Math.min(Math.max(t,n),r)}),i=function(n){return n*Math.PI/180},f=function(n){return n.hasOwnProperty("x")&&n.hasOwnProperty("y")},c=function(n){return f(n)&&n.hasOwnProperty("z")},s=function(n,r){return Math.abs(n-r)},p=function(n,r,t){var e=r-n;return 0===e?1:(t-n)/e},h=function(n,r,t){return-t*n+t*r+n},l=function(){return(l=Object.assign||function(n){for(var r,t=1,e=arguments.length;t<e;t++)for(var u in r=arguments[t])Object.prototype.hasOwnProperty.call(r,u)&&(n[u]=r[u]);return n}).apply(this,arguments)},d=function(){return(d=Object.assign||function(n){for(var r,t=1,e=arguments.length;t<e;t++)for(var u in r=arguments[t])Object.prototype.hasOwnProperty.call(r,u)&&(n[u]=r[u]);return n}).apply(this,arguments)},v=function(n,r){return function(t){return Math.max(Math.min(t,r),n)}},m=function(n){return function(r){return"string"==typeof r&&0===r.indexOf(n)}},g=function(n){return n%1?Number(n.toFixed(5)):n},y={test:function(n){return"number"==typeof n},parse:parseFloat,transform:function(n){return n}},b=(d({},y,{transform:v(0,1)}),d({},y,{default:1}),r="%",{test:function(n){return"string"==typeof n&&n.endsWith(r)&&1===n.split(" ").length},parse:parseFloat,transform:function(n){return""+n+r}}),M=v(0,255),x=/^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d\.]+%?\))$/i,w=function(n){return void 0!==n.red},O=function(n){return void 0!==n.hue},A=function(n){var r=n.length;return function(t){if("string"!=typeof t)return t;for(var e,u={},a=function(n){return"string"==typeof n?n.split(/,\s*/):[n]}((e=t).substring(e.indexOf("(")+1,e.lastIndexOf(")"))),o=0;o<r;o++)u[n[o]]=void 0!==a[o]?parseFloat(a[o]):1;return u}},F=d({},y,{transform:function(n){return Math.round(M(n))}}),I=m("rgb"),P={test:function(n){return"string"==typeof n?I(n):w(n)},parse:A(["red","green","blue","alpha"]),transform:function(n){var r=n.red,t=n.green,e=n.blue,u=n.alpha;return function(n){var r=n.red,t=n.green,e=n.blue,u=n.alpha;return"rgba("+r+", "+t+", "+e+", "+(void 0===u?1:u)+")"}({red:F.transform(r),green:F.transform(t),blue:F.transform(e),alpha:g(u)})}},R=m("hsl"),E={test:function(n){return"string"==typeof n?R(n):O(n)},parse:A(["hue","saturation","lightness","alpha"]),transform:function(n){var r=n.hue,t=n.saturation,e=n.lightness,u=n.alpha;return function(n){var r=n.hue,t=n.saturation,e=n.lightness,u=n.alpha;return"hsla("+r+", "+t+", "+e+", "+(void 0===u?1:u)+")"}({hue:Math.round(r),saturation:b.transform(g(t)),lightness:b.transform(g(e)),alpha:g(u)})}},S=d({},P,{test:m("#"),parse:function(n){var r="",t="",e="";return n.length>4?(r=n.substr(1,2),t=n.substr(3,2),e=n.substr(5,2)):(r=n.substr(1,1),t=n.substr(2,1),e=n.substr(3,1),r+=r,t+=t,e+=e),{red:parseInt(r,16),green:parseInt(t,16),blue:parseInt(e,16),alpha:1}}}),j=function(n){return"string"==typeof n&&x.test(n)||P.test(n)||E.test(n)||S.test(n)},k=function(n){return P.test(n)?P.parse(n):E.test(n)?E.parse(n):S.test(n)?S.parse(n):n},$=function(n){return w(n)?P.transform(n):O(n)?E.transform(n):n},q=/(-)?(\d[\d\.]*)/g,z=/(#[0-9a-f]{6}|#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d\.]+%?\))/gi,B=function(n){var r=n,t=[],e=r.match(z);e&&(r=r.replace(z,"${c}"),t.push.apply(t,e.map(k)));var u=r.match(q);return u&&t.push.apply(t,u.map(y.parse)),t},D=function(n){var r=n,t=0,e=n.match(z),u=e?e.length:0;if(e)for(var a=0;a<u;a++)r=r.replace(e[a],"${c}"),t++;var o=r.match(q),i=o?o.length:0;if(o)for(a=0;a<i;a++)r=r.replace(o[a],"${n}"),t++;return function(n){for(var e=r,a=0;a<t;a++)e=e.replace(a<u?"${c}":"${n}",a<u?$(n[a]):g(n[a]));return e}},U=function(){};"production"!==process.env.NODE_ENV&&(U=function(n,r){if(!n)throw new Error("Hey, listen! ".toUpperCase()+r)});var C,H=function(n,r,t){var e=n*n,u=r*r;return Math.sqrt(t*(u-e)+e)},N=[S,P,E],T=function(n){return N.find(function(r){return r.test(n)})},V=function(n,r){var t=T(n),e=T(r);U(t.transform===e.transform,"Both colors must be Hex and/or RGBA, or both must be HSLA");var u=t.parse(n),a=e.parse(r),o=l({},u),i=t===E?h:H;return function(n){for(var r in o)"alpha"!==r&&(o[r]=i(u[r],a[r],n));return o.alpha=h(u.alpha,a.alpha,n),t.transform(o)}},W=function(n,r){return function(t){return r(n(t))}},_=function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return n.reduce(W)},L=function(n,r){var t=n.slice(),u=t.length,a=n.map(function(n,t){var u=r[t];return e(n)?function(r){return h(n,u,r)}:j(n)?V(n,u):G(n,u)});return function(n){for(var r=0;r<u;r++)t[r]=a[r](n);return t}},G=function(n,r){var t=D(n);return U(t(n)===D(r)(n),"Values '"+n+"' and '"+r+"' are of different format, or a value might have changed value type."),_(L(B(n),B(r)),t)},J=a(h),K=function(n,r){return Array(n.length-1).fill((t=n[0],"number"==typeof t?J:j(t)?V:G)).map(function(t,e){var u=t(n[e],n[e+1]);if(r){var a=Array.isArray(r)?r[e]:r;return _(a,u)}return u});var t},Q=function(n,r){return void 0===r&&(r=2),r=Math.pow(10,r),Math.round(n*r)/r},X=function(n,r,t,e){return void 0===e&&(e=0),Q(n+t*(r-n)/Math.max(e,t))},Y=0,Z="undefined"!=typeof window&&void 0!==window.requestAnimationFrame?function(n){return window.requestAnimationFrame(n)}:function(n){var r=Date.now(),t=Math.max(0,16.7-(r-Y));Y=r+t,setTimeout(function(){return n(Y)},t)};!function(n){n.Read="read",n.Update="update",n.Render="render",n.PostRender="postRender",n.FixedUpdate="fixedUpdate"}(C||(C={}));var nn=1/60*1e3,rn=!0,tn=!1,en=!1,un={delta:0,timestamp:0},an=[C.Read,C.Update,C.Render,C.PostRender],on=function(n){return tn=n},fn=an.reduce(function(n,r){var t,e,u,a,o,i,f,c,s,p=(t=on,e=[],u=[],a=0,o=!1,i=0,f=new WeakSet,c=new WeakSet,s={cancel:function(n){var r=u.indexOf(n);f.add(n),-1!==r&&u.splice(r,1)},process:function(n){var r,p;if(o=!0,e=(r=[u,e])[0],(u=r[1]).length=0,a=e.length)for(i=0;i<a;i++)(p=e[i])(n),!0!==c.has(p)||f.has(p)||(s.schedule(p),t(!0));o=!1},schedule:function(n,r,t){U("function"==typeof n,"Argument must be a function");var i=t&&o,f=i?e:u;r&&c.add(n),-1===f.indexOf(n)&&(f.push(n),i&&(a=e.length))}});return n.sync[r]=function(n,r,t){return void 0===r&&(r=!1),void 0===t&&(t=!1),tn||hn(),p.schedule(n,r,t),n},n.cancelSync[r]=function(n){return p.cancel(n)},n.steps[r]=p,n},{steps:{},sync:{},cancelSync:{}}),cn=fn.steps,sn=(fn.sync,fn.cancelSync,function(n){return cn[n].process(un)}),pn=function(n){tn=!1,un.delta=rn?nn:Math.max(Math.min(n-un.timestamp,40),1),rn||(nn=un.delta),un.timestamp=n,en=!0,an.forEach(sn),en=!1,tn&&(rn=!1,Z(pn))},hn=function(){tn=!0,rn=!0,en||Z(pn)},ln=function(n){return n},dn=function(n){return void 0===n&&(n=ln),a(function(r,t,e){var u=t-e,a=-(0-r+1)*(0-n(Math.abs(u)));return u<=0?t+a:t-a})},vn=dn(),mn=dn(Math.sqrt),gn=a(function(n,r,t){var e=r-n;return((t-n)%e+e)%e+n}),yn=o(0,1),bn=function(n){return function(r){return 1-n(1-r)}},Mn=function(n){return function(r){return r<=.5?n(2*r)/2:(2-n(2*(1-r)))/2}},xn=function(n){return function(r){return Math.pow(r,n)}},wn=function(n){return function(r){return r*r*((n+1)*r-n)}},On=function(n){var r=wn(n);return function(n){return(n*=2)<1?.5*r(n):.5*(2-Math.pow(2,-10*(n-1)))}},An=xn(2),Fn=bn(An),In=Mn(An),Pn=function(n){return 1-Math.sin(Math.acos(n))},Rn=bn(Pn),En=Mn(Rn),Sn=wn(1.525),jn=bn(Sn),kn=Mn(Sn),$n=On(1.525),qn=8,zn=.001,Bn=1e-7,Dn=10,Un=11,Cn=1/(Un-1),Hn="undefined"!=typeof Float32Array,Nn=function(n,r){return 1-3*r+3*n},Tn=function(n,r){return 3*r-6*n},Vn=function(n){return 3*n},Wn=function(n,r,t){return 3*Nn(r,t)*n*n+2*Tn(r,t)*n+Vn(r)},_n=function(n,r,t){return((Nn(r,t)*n+Tn(r,t))*n+Vn(r))*n};n.angle=function(n,r){return void 0===r&&(r=t),u(Math.atan2(r.y-n.y,r.x-n.x))},n.applyOffset=function(n,r){var t=!0;return void 0===r&&(r=n,t=!1),function(e){return t?e-n+r:(n=e,t=!0,r)}},n.clamp=o,n.conditional=function(n,r){return function(t){return n(t)?r(t):t}},n.degreesToRadians=i,n.distance=function(n,r){if(void 0===r&&(r=t),e(n)&&e(r))return s(n,r);if(f(n)&&f(r)){var u=s(n.x,r.x),a=s(n.y,r.y),o=c(n)&&c(r)?s(n.z,r.z):0;return Math.sqrt(Math.pow(u,2)+Math.pow(a,2)+Math.pow(o,2))}return 0},n.interpolate=function(n,r,t){var e=void 0===t?{}:t,u=e.clamp,a=void 0===u||u,i=e.ease,f=n.length;U(f===r.length,"Both input and output ranges must be the same length"),U(!i||!Array.isArray(i)||i.length===n.length-1,"Array of easing functions must be of length `input.length - 1`, as it applies to the transitions **between** the defined values."),n[0]>n[f-1]&&(n=n.slice(),r=r.slice(),n.reverse(),r.reverse());var c=K(r,i),s=2===f?function(n,r){var t=n[0],e=n[1],u=r[0];return function(n){return u(p(t,e,n))}}(n,c):function(n,r){var t=n.length,e=t-1;return function(u){var a=0,o=!1;if(u<=n[0]?o=!0:u>=n[e]&&(a=e-1,o=!0),!o){for(var i=1;i<t&&!(n[i]>u||i===e);i++);a=i-1}var f=p(n[a],n[a+1],u);return r[a](f)}}(n,c);return a?_(o(n[0],n[f-1]),s):s},n.isPoint=f,n.isPoint3D=c,n.mix=h,n.mixArray=L,n.mixColor=V,n.mixComplex=G,n.pipe=_,n.pointFromVector=function(n,r,t){return r=i(r),{x:t*Math.cos(r)+n.x,y:t*Math.sin(r)+n.y}},n.progress=p,n.radiansToDegrees=u,n.smooth=function(n){void 0===n&&(n=50);var r=0,t=0;return function(e){var u=un.timestamp,a=u!==t?u-t:0,o=a?X(r,e,a,n):r;return t=u,r=o,o}},n.smoothFrame=X,n.snap=function(n){if("number"==typeof n)return function(r){return Math.round(r/n)*n};var r=0,t=n.length;return function(e){var u=Math.abs(n[0]-e);for(r=1;r<t;r++){var a=n[r],o=Math.abs(a-e);if(0===o)return a;if(o>u)return n[r-1];if(r===t-1)return a;u=o}}},n.springForce=dn,n.springForceExpo=mn,n.springForceLinear=vn,n.steps=function(n,r){return void 0===r&&(r="end"),function(t){var e=(t="end"===r?Math.min(t,.999):Math.max(t,.001))*n,u="end"===r?Math.floor(e):Math.ceil(e);return yn(u/n)}},n.toDecimal=Q,n.velocityPerFrame=function(n,r){return e(n)?n/(1e3/r):0},n.velocityPerSecond=function(n,r){return r?n*(1e3/r):0},n.wrap=gn,n.createAnticipateEasing=On,n.createBackIn=wn,n.createExpoIn=xn,n.cubicBezier=function(n,r,t,e){var u=Hn?new Float32Array(Un):new Array(Un),a=function(r){for(var e,a,o,i=0,f=1,c=Un-1;f!==c&&u[f]<=r;++f)i+=Cn;return e=(r-u[--f])/(u[f+1]-u[f]),(o=Wn(a=i+e*Cn,n,t))>=zn?function(r,e){for(var u=0,a=0;u<qn;++u){if(0===(a=Wn(e,n,t)))return e;e-=(_n(e,n,t)-r)/a}return e}(r,a):0===o?a:function(r,e,u){var a,o,i=0;do{(a=_n(o=e+(u-e)/2,n,t)-r)>0?u=o:e=o}while(Math.abs(a)>Bn&&++i<Dn);return o}(r,i,i+Cn)};return function(){for(var r=0;r<Un;++r)u[r]=_n(r*Cn,n,t)}(),function(u){return n===r&&t===e?u:0===u?0:1===u?1:_n(a(u),r,e)}},n.linear=function(n){return n},n.easeIn=An,n.easeOut=Fn,n.easeInOut=In,n.circIn=Pn,n.circOut=Rn,n.circInOut=En,n.backIn=Sn,n.backOut=jn,n.backInOut=kn,n.anticipate=$n,n.reversed=bn,n.mirrored=Mn,Object.defineProperty(n,"__esModule",{value:!0})}); | ||
!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r(n.popcorn={})}(this,function(n){"use strict";var r,t={x:0,y:0,z:0},e=function(n){return"number"==typeof n},u=function(n){return 180*n/Math.PI},a=function(n){return function(r,t,e){return void 0!==e?n(r,t,e):function(e){return n(r,t,e)}}},o=a(function(n,r,t){return Math.min(Math.max(t,n),r)}),i=function(n){return n*Math.PI/180},f=function(n){return n.hasOwnProperty("x")&&n.hasOwnProperty("y")},c=function(n){return f(n)&&n.hasOwnProperty("z")},s=function(n,r){return Math.abs(n-r)},p=function(n,r,t){var e=r-n;return 0===e?1:(t-n)/e},h=function(n,r,t){return-t*n+t*r+n},d=function(){return(d=Object.assign||function(n){for(var r,t=1,e=arguments.length;t<e;t++)for(var u in r=arguments[t])Object.prototype.hasOwnProperty.call(r,u)&&(n[u]=r[u]);return n}).apply(this,arguments)},l=function(){return(l=Object.assign||function(n){for(var r,t=1,e=arguments.length;t<e;t++)for(var u in r=arguments[t])Object.prototype.hasOwnProperty.call(r,u)&&(n[u]=r[u]);return n}).apply(this,arguments)},v=function(n,r){return function(t){return Math.max(Math.min(t,r),n)}},m=function(n){return function(r){return"string"==typeof r&&0===r.indexOf(n)}},g=function(n){return n%1?Number(n.toFixed(5)):n},y={test:function(n){return"number"==typeof n},parse:parseFloat,transform:function(n){return n}},b=(l({},y,{transform:v(0,1)}),l({},y,{default:1}),r="%",{test:function(n){return"string"==typeof n&&n.endsWith(r)&&1===n.split(" ").length},parse:parseFloat,transform:function(n){return""+n+r}}),M=(l({},b,{parse:function(n){return b.parse(n)/100},transform:function(n){return b.transform(100*n)}}),v(0,255)),x=/^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d\.]+%?\))$/i,w=function(n){return void 0!==n.red},O=function(n){return void 0!==n.hue},A=function(n){var r=n.length;return function(t){if("string"!=typeof t)return t;for(var e,u={},a=function(n){return"string"==typeof n?n.split(/,\s*/):[n]}((e=t).substring(e.indexOf("(")+1,e.lastIndexOf(")"))),o=0;o<r;o++)u[n[o]]=void 0!==a[o]?parseFloat(a[o]):1;return u}},F=l({},y,{transform:function(n){return Math.round(M(n))}}),I=m("rgb"),P={test:function(n){return"string"==typeof n?I(n):w(n)},parse:A(["red","green","blue","alpha"]),transform:function(n){var r=n.red,t=n.green,e=n.blue,u=n.alpha;return function(n){var r=n.red,t=n.green,e=n.blue,u=n.alpha;return"rgba("+r+", "+t+", "+e+", "+(void 0===u?1:u)+")"}({red:F.transform(r),green:F.transform(t),blue:F.transform(e),alpha:g(u)})}},R=m("hsl"),E={test:function(n){return"string"==typeof n?R(n):O(n)},parse:A(["hue","saturation","lightness","alpha"]),transform:function(n){var r=n.hue,t=n.saturation,e=n.lightness,u=n.alpha;return function(n){var r=n.hue,t=n.saturation,e=n.lightness,u=n.alpha;return"hsla("+r+", "+t+", "+e+", "+(void 0===u?1:u)+")"}({hue:Math.round(r),saturation:b.transform(g(t)),lightness:b.transform(g(e)),alpha:g(u)})}},S=l({},P,{test:m("#"),parse:function(n){var r="",t="",e="";return n.length>4?(r=n.substr(1,2),t=n.substr(3,2),e=n.substr(5,2)):(r=n.substr(1,1),t=n.substr(2,1),e=n.substr(3,1),r+=r,t+=t,e+=e),{red:parseInt(r,16),green:parseInt(t,16),blue:parseInt(e,16),alpha:1}}}),j=function(n){return"string"==typeof n&&x.test(n)||P.test(n)||E.test(n)||S.test(n)},k=function(n){return P.test(n)?P.parse(n):E.test(n)?E.parse(n):S.test(n)?S.parse(n):n},$=function(n){return w(n)?P.transform(n):O(n)?E.transform(n):n},q=/(-)?(\d[\d\.]*)/g,z=/(#[0-9a-f]{6}|#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d\.]+%?\))/gi,B=function(n){var r=n,t=[],e=r.match(z);e&&(r=r.replace(z,"${c}"),t.push.apply(t,e.map(k)));var u=r.match(q);return u&&t.push.apply(t,u.map(y.parse)),t},D=function(n){var r=n,t=0,e=n.match(z),u=e?e.length:0;if(e)for(var a=0;a<u;a++)r=r.replace(e[a],"${c}"),t++;var o=r.match(q),i=o?o.length:0;if(o)for(a=0;a<i;a++)r=r.replace(o[a],"${n}"),t++;return function(n){for(var e=r,a=0;a<t;a++)e=e.replace(a<u?"${c}":"${n}",a<u?$(n[a]):g(n[a]));return e}},U=function(){};"production"!==process.env.NODE_ENV&&(U=function(n,r){if(!n)throw new Error("Hey, listen! ".toUpperCase()+r)});var C=function(n,r,t){var e=n*n,u=r*r;return Math.sqrt(t*(u-e)+e)},H=[S,P,E],N=function(n){return H.find(function(r){return r.test(n)})},T=function(n,r){var t=N(n),e=N(r);U(t.transform===e.transform,"Both colors must be Hex and/or RGBA, or both must be HSLA");var u=t.parse(n),a=e.parse(r),o=d({},u),i=t===E?h:C;return function(n){for(var r in o)"alpha"!==r&&(o[r]=i(u[r],a[r],n));return o.alpha=h(u.alpha,a.alpha,n),t.transform(o)}},V=function(n,r){return function(t){return r(n(t))}},W=function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return n.reduce(V)},_=function(n,r){var t=n.slice(),u=t.length,a=n.map(function(n,t){var u=r[t];return e(n)?function(r){return h(n,u,r)}:j(n)?T(n,u):L(n,u)});return function(n){for(var r=0;r<u;r++)t[r]=a[r](n);return t}},L=function(n,r){var t=D(n);return U(t(n)===D(r)(n),"Values '"+n+"' and '"+r+"' are of different format, or a value might have changed value type."),W(_(B(n),B(r)),t)},G=a(h),J=function(n,r){return Array(n.length-1).fill((t=n[0],"number"==typeof t?G:j(t)?T:L)).map(function(t,e){var u=t(n[e],n[e+1]);if(r){var a=Array.isArray(r)?r[e]:r;return W(a,u)}return u});var t},K=function(n,r){var t=n[0],e=n[1],u=r[0];return function(n){return u(p(t,e,n))}},Q=function(n,r){var t=n.length,e=t-1;return function(u){var a=0,o=!1;if(u<=n[0]?o=!0:u>=n[e]&&(a=e-1,o=!0),!o){for(var i=1;i<t&&!(n[i]>u||i===e);i++);a=i-1}var f=p(n[a],n[a+1],u);return r[a](f)}};var X,Y=function(n,r){return void 0===r&&(r=2),r=Math.pow(10,r),Math.round(n*r)/r},Z=function(n,r,t,e){return void 0===e&&(e=0),Y(n+t*(r-n)/Math.max(e,t))},nn=0,rn="undefined"!=typeof window&&void 0!==window.requestAnimationFrame?function(n){return window.requestAnimationFrame(n)}:function(n){var r=Date.now(),t=Math.max(0,16.7-(r-nn));nn=r+t,setTimeout(function(){return n(nn)},t)};!function(n){n.Read="read",n.Update="update",n.Render="render",n.PostRender="postRender",n.FixedUpdate="fixedUpdate"}(X||(X={}));var tn=1/60*1e3,en=!0,un=!1,an=!1,on={delta:0,timestamp:0},fn=[X.Read,X.Update,X.Render,X.PostRender],cn=function(n){return un=n},sn=fn.reduce(function(n,r){var t,e,u,a,o,i,f,c,s,p=(t=cn,e=[],u=[],a=0,o=!1,i=0,f=new WeakSet,c=new WeakSet,s={cancel:function(n){var r=u.indexOf(n);f.add(n),-1!==r&&u.splice(r,1)},process:function(n){var r,p;if(o=!0,e=(r=[u,e])[0],(u=r[1]).length=0,a=e.length)for(i=0;i<a;i++)(p=e[i])(n),!0!==c.has(p)||f.has(p)||(s.schedule(p),t(!0));o=!1},schedule:function(n,r,t){void 0===r&&(r=!1),void 0===t&&(t=!1),U("function"==typeof n,"Argument must be a function");var i=t&&o,s=i?e:u;f.delete(n),r&&c.add(n),-1===s.indexOf(n)&&(s.push(n),i&&(a=e.length))}});return n.sync[r]=function(n,r,t){return void 0===r&&(r=!1),void 0===t&&(t=!1),un||ln(),p.schedule(n,r,t),n},n.cancelSync[r]=function(n){return p.cancel(n)},n.steps[r]=p,n},{steps:{},sync:{},cancelSync:{}}),pn=sn.steps,hn=(sn.sync,sn.cancelSync,function(n){return pn[n].process(on)}),dn=function(n){un=!1,on.delta=en?tn:Math.max(Math.min(n-on.timestamp,40),1),en||(tn=on.delta),on.timestamp=n,an=!0,fn.forEach(hn),an=!1,un&&(en=!1,rn(dn))},ln=function(){un=!0,en=!0,an||rn(dn)},vn=function(n){return n},mn=function(n){return void 0===n&&(n=vn),a(function(r,t,e){var u=t-e,a=-(0-r+1)*(0-n(Math.abs(u)));return u<=0?t+a:t-a})},gn=mn(),yn=mn(Math.sqrt),bn=a(function(n,r,t){var e=r-n;return((t-n)%e+e)%e+n}),Mn=o(0,1),xn=function(n){return function(r){return 1-n(1-r)}},wn=function(n){return function(r){return r<=.5?n(2*r)/2:(2-n(2*(1-r)))/2}},On=function(n){return function(r){return Math.pow(r,n)}},An=function(n){return function(r){return r*r*((n+1)*r-n)}},Fn=function(n){var r=An(n);return function(n){return(n*=2)<1?.5*r(n):.5*(2-Math.pow(2,-10*(n-1)))}},In=On(2),Pn=xn(In),Rn=wn(In),En=function(n){return 1-Math.sin(Math.acos(n))},Sn=xn(En),jn=wn(Sn),kn=An(1.525),$n=xn(kn),qn=wn(kn),zn=Fn(1.525),Bn=8,Dn=.001,Un=1e-7,Cn=10,Hn=11,Nn=1/(Hn-1),Tn="undefined"!=typeof Float32Array,Vn=function(n,r){return 1-3*r+3*n},Wn=function(n,r){return 3*r-6*n},_n=function(n){return 3*n},Ln=function(n,r,t){return 3*Vn(r,t)*n*n+2*Wn(r,t)*n+_n(r)},Gn=function(n,r,t){return((Vn(r,t)*n+Wn(r,t))*n+_n(r))*n};n.angle=function(n,r){return void 0===r&&(r=t),u(Math.atan2(r.y-n.y,r.x-n.x))},n.applyOffset=function(n,r){var t=!0;return void 0===r&&(r=n,t=!1),function(e){return t?e-n+r:(n=e,t=!0,r)}},n.clamp=o,n.conditional=function(n,r){return function(t){return n(t)?r(t):t}},n.degreesToRadians=i,n.distance=function(n,r){if(void 0===r&&(r=t),e(n)&&e(r))return s(n,r);if(f(n)&&f(r)){var u=s(n.x,r.x),a=s(n.y,r.y),o=c(n)&&c(r)?s(n.z,r.z):0;return Math.sqrt(Math.pow(u,2)+Math.pow(a,2)+Math.pow(o,2))}return 0},n.interpolate=function(n,r,t){var e=void 0===t?{}:t,u=e.clamp,a=void 0===u||u,i=e.ease,f=n.length;U(f===r.length,"Both input and output ranges must be the same length"),U(!i||!Array.isArray(i)||i.length===f-1,"Array of easing functions must be of length `input.length - 1`, as it applies to the transitions **between** the defined values."),n[0]>n[f-1]&&(n=[].concat(n),r=[].concat(r),n.reverse(),r.reverse());var c=J(r,i),s=2===f?K(n,c):Q(n,c);return a?W(o(n[0],n[f-1]),s):s},n.isPoint=f,n.isPoint3D=c,n.mix=h,n.mixArray=_,n.mixColor=T,n.mixComplex=L,n.pipe=W,n.pointFromVector=function(n,r,t){return r=i(r),{x:t*Math.cos(r)+n.x,y:t*Math.sin(r)+n.y}},n.progress=p,n.radiansToDegrees=u,n.smooth=function(n){void 0===n&&(n=50);var r=0,t=0;return function(e){var u=on.timestamp,a=u!==t?u-t:0,o=a?Z(r,e,a,n):r;return t=u,r=o,o}},n.smoothFrame=Z,n.snap=function(n){if("number"==typeof n)return function(r){return Math.round(r/n)*n};var r=0,t=n.length;return function(e){var u=Math.abs(n[0]-e);for(r=1;r<t;r++){var a=n[r],o=Math.abs(a-e);if(0===o)return a;if(o>u)return n[r-1];if(r===t-1)return a;u=o}}},n.springForce=mn,n.springForceExpo=yn,n.springForceLinear=gn,n.steps=function(n,r){return void 0===r&&(r="end"),function(t){var e=(t="end"===r?Math.min(t,.999):Math.max(t,.001))*n,u="end"===r?Math.floor(e):Math.ceil(e);return Mn(u/n)}},n.toDecimal=Y,n.velocityPerFrame=function(n,r){return e(n)?n/(1e3/r):0},n.velocityPerSecond=function(n,r){return r?n*(1e3/r):0},n.wrap=bn,n.createAnticipateEasing=Fn,n.createBackIn=An,n.createExpoIn=On,n.cubicBezier=function(n,r,t,e){var u=Tn?new Float32Array(Hn):new Array(Hn),a=function(r){for(var e,a,o,i=0,f=1,c=Hn-1;f!==c&&u[f]<=r;++f)i+=Nn;return e=(r-u[--f])/(u[f+1]-u[f]),(o=Ln(a=i+e*Nn,n,t))>=Dn?function(r,e){for(var u=0,a=0;u<Bn;++u){if(0===(a=Ln(e,n,t)))return e;e-=(Gn(e,n,t)-r)/a}return e}(r,a):0===o?a:function(r,e,u){var a,o,i=0;do{(a=Gn(o=e+(u-e)/2,n,t)-r)>0?u=o:e=o}while(Math.abs(a)>Un&&++i<Cn);return o}(r,i,i+Nn)};return function(){for(var r=0;r<Hn;++r)u[r]=Gn(r*Nn,n,t)}(),function(u){return n===r&&t===e?u:0===u?0:1===u?1:Gn(a(u),r,e)}},n.linear=function(n){return n},n.easeIn=In,n.easeOut=Pn,n.easeInOut=Rn,n.circIn=En,n.circOut=Sn,n.circInOut=jn,n.backIn=kn,n.backOut=$n,n.backInOut=qn,n.anticipate=zn,n.reversed=xn,n.mirrored=wn,Object.defineProperty(n,"__esModule",{value:!0})}); |
@@ -231,10 +231,10 @@ 'use strict'; | ||
}; | ||
var interpolate = (function (input, output, _a) { | ||
function interpolate(input, output, _a) { | ||
var _b = _a === void 0 ? {} : _a, _c = _b.clamp, clamp = _c === void 0 ? true : _c, ease = _b.ease; | ||
var inputLength = input.length; | ||
heyListen.invariant(inputLength === output.length, 'Both input and output ranges must be the same length'); | ||
heyListen.invariant(!ease || !Array.isArray(ease) || ease.length === input.length - 1, 'Array of easing functions must be of length `input.length - 1`, as it applies to the transitions **between** the defined values.'); | ||
heyListen.invariant(!ease || !Array.isArray(ease) || ease.length === inputLength - 1, 'Array of easing functions must be of length `input.length - 1`, as it applies to the transitions **between** the defined values.'); | ||
if (input[0] > input[inputLength - 1]) { | ||
input = input.slice(); | ||
output = output.slice(); | ||
input = [].concat(input); | ||
output = [].concat(output); | ||
input.reverse(); | ||
@@ -244,9 +244,9 @@ output.reverse(); | ||
var mixers = createMixers(output, ease); | ||
var interpolate = inputLength === 2 | ||
var interpolator = inputLength === 2 | ||
? fastInterpolate(input, mixers) | ||
: slowInterpolate(input, mixers); | ||
return clamp | ||
? pipe(clamp$1(input[0], input[inputLength - 1]), interpolate) | ||
: interpolate; | ||
}); | ||
? pipe(clamp$1(input[0], input[inputLength - 1]), interpolator) | ||
: interpolator; | ||
} | ||
@@ -253,0 +253,0 @@ var pointFromVector = (function (origin, angle, distance) { |
import { Easing } from '@popmotion/easing'; | ||
declare type Mixer = (v: number) => number | string; | ||
declare type Ease = Easing | Easing[]; | ||
declare type Interpolate<T> = (v: number) => T; | ||
declare type InterpolateOptions = { | ||
clamp?: boolean; | ||
ease?: Easing | Easing[]; | ||
ease?: Ease; | ||
}; | ||
declare const _default: (input: number[], output: number[] | string[], { clamp, ease }?: InterpolateOptions) => Mixer; | ||
export default _default; | ||
declare function interpolate(input: number[], output: number[], options?: InterpolateOptions): Interpolate<number>; | ||
declare function interpolate(input: number[], output: string[], options?: InterpolateOptions): Interpolate<string>; | ||
export default interpolate; |
MIT License | ||
Copyright (c) 2018 Inventing With Monster Ltd | ||
Copyright © 2019 Framer BV | ||
@@ -5,0 +5,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy |
{ | ||
"name": "@popmotion/popcorn", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"description": "Utility functions for animation and interactions.", | ||
@@ -70,4 +70,4 @@ "main": "lib/index.js", | ||
"hey-listen": "^1.0.5", | ||
"style-value-types": "^3.0.7" | ||
"style-value-types": "^3.1.0" | ||
} | ||
} |
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
82393
1696
Updatedstyle-value-types@^3.1.0