Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@popmotion/popcorn

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@popmotion/popcorn - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

12

CHANGELOG.md

@@ -5,4 +5,14 @@ # Changelog

## [1.0.0] 2018-09-30
## [0.1.1] 2018-11-01
### Republish
## [0.1.0] 2018-10-31
### Added
- Exposing `springForce, springForceLinear, springForceExpo` - these are currently private for use in Popmotion libraries.
## [0.0.1] 2018-09-30
### First publish

@@ -285,2 +285,16 @@ import { hsla, rgba, hex, color, complex } from 'style-value-types';

var identity = function (v) { return v; };
var springForce = function (alterDisplacement) {
if (alterDisplacement === void 0) { alterDisplacement = identity; }
return curryRange(function (constant, origin, v) {
var displacement = origin - v;
var springModifiedDisplacement = -(0 - constant + 1) * (0 - alterDisplacement(Math.abs(displacement)));
return displacement <= 0
? origin + springModifiedDisplacement
: origin - springModifiedDisplacement;
});
};
var springForceLinear = springForce();
var springForceExpo = springForce(Math.sqrt);
var velocityPerFrame = (function (xps, frameDuration) {

@@ -312,2 +326,2 @@ return isNum(xps) ? xps / (1000 / frameDuration) : 0;

export { angle, applyOffset, clamp$1 as clamp, degreesToRadians, dilate, distance, isPoint, isPoint3D, pointFromVector, progress, radiansToDegrees, smooth, velocityPerFrame, velocityPerSecond, toDecimal, wrap$1 as wrap, steps, snap, smoothFrame, pipe, mixArray, mixColor, interpolate, conditional, mix, mixComplex };
export { angle, applyOffset, clamp$1 as clamp, conditional, degreesToRadians, dilate, distance, interpolate, isPoint, isPoint3D, mix, mixArray, mixColor, mixComplex, pipe, pointFromVector, progress, radiansToDegrees, smooth, smoothFrame, snap, springForce, springForceExpo, springForceLinear, steps, toDecimal, velocityPerFrame, velocityPerSecond, wrap$1 as wrap };

39

dist/popcorn.js

@@ -653,2 +653,16 @@ (function (global, factory) {

var identity = function (v) { return v; };
var springForce = function (alterDisplacement) {
if (alterDisplacement === void 0) { alterDisplacement = identity; }
return curryRange(function (constant, origin, v) {
var displacement = origin - v;
var springModifiedDisplacement = -(0 - constant + 1) * (0 - alterDisplacement(Math.abs(displacement)));
return displacement <= 0
? origin + springModifiedDisplacement
: origin - springModifiedDisplacement;
});
};
var springForceLinear = springForce();
var springForceExpo = springForce(Math.sqrt);
var velocityPerFrame = (function (xps, frameDuration) {

@@ -822,7 +836,14 @@ return isNum(xps) ? xps / (1000 / frameDuration) : 0;

exports.clamp = clamp$1;
exports.conditional = conditional;
exports.degreesToRadians = degreesToRadians;
exports.dilate = dilate;
exports.distance = distance;
exports.interpolate = interpolate;
exports.isPoint = isPoint;
exports.isPoint3D = isPoint3D;
exports.mix = mix;
exports.mixArray = mixArray;
exports.mixColor = mixColor;
exports.mixComplex = mixComplex;
exports.pipe = pipe;
exports.pointFromVector = pointFromVector;

@@ -832,16 +853,12 @@ exports.progress = progress;

exports.smooth = smooth;
exports.smoothFrame = smoothFrame;
exports.snap = snap;
exports.springForce = springForce;
exports.springForceExpo = springForceExpo;
exports.springForceLinear = springForceLinear;
exports.steps = steps$1;
exports.toDecimal = toDecimal;
exports.velocityPerFrame = velocityPerFrame;
exports.velocityPerSecond = velocityPerSecond;
exports.toDecimal = toDecimal;
exports.wrap = wrap$1;
exports.steps = steps$1;
exports.snap = snap;
exports.smoothFrame = smoothFrame;
exports.pipe = pipe;
exports.mixArray = mixArray;
exports.mixColor = mixColor;
exports.interpolate = interpolate;
exports.conditional = conditional;
exports.mix = mix;
exports.mixComplex = mixComplex;
exports.createAnticipateEasing = createAnticipateEasing;

@@ -848,0 +865,0 @@ exports.createBackIn = createBackIn;

@@ -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},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)}},y=function(n){return n%1?Number(n.toFixed(5)):n},g={test:function(n){return"number"==typeof n},parse:parseFloat,transform:function(n){return n}},b=(l({},g,{transform:v(0,1)}),l({},g,{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},I=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}},P=l({},g,{transform:function(n){return Math.round(M(n))}}),F=m("rgb"),A={test:function(n){return"string"==typeof n?F(n):w(n)},parse:I(["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:P.transform(r),green:P.transform(t),blue:P.transform(e),alpha:y(u)})}},R=m("hsl"),S={test:function(n){return"string"==typeof n?R(n):O(n)},parse:I(["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(y(t)),lightness:b.transform(y(e)),alpha:y(u)})}},j=l({},A,{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}}}),k=function(n){return"string"==typeof n&&x.test(n)||A.test(n)||S.test(n)||j.test(n)},E=function(n){return A.test(n)?A.parse(n):S.test(n)?S.parse(n):j.test(n)?j.parse(n):n},$=function(n){return w(n)?A.transform(n):O(n)?S.transform(n):n},z=/(-)?(\d[\d\.]*)/g,D=/(#[0-9a-f]{6}|#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d\.]+%?\))/gi,U=function(n){var r=n,t=[],e=r.match(D);e&&(r=r.replace(D,"${c}"),t.push.apply(t,e.map(E)));var u=r.match(z);return u&&t.push.apply(t,u.map(g.parse)),t},q=function(n){var r=n,t=0,e=n.match(D),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(z),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]):y(n[a]));return e}},B=function(){};"production"!==process.env.NODE_ENV&&(B=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=[j,A,S],T=function(n){return N.find(function(r){return r.test(n)})},V=function(n,r){var t=T(n),e=T(r);B(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===S?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)},G=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)}:k(n)?V(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=q(n);return B(t(n)===q(r)(n),"Values '"+n+"' and '"+r+"' are of different format, or a value might have changed value type."),_(G(U(n),U(r)),t)},J=a(h),K=function(n,r,t,e){var u=t-1;n[0]>n[u]&&(n.reverse(),r.reverse());var a,o=Array(u).fill("number"==typeof(a=r[0])?J:k(a)?V:L).map(function(n,t){return n(r[t],r[t+1])});return function(a){if(a<=n[0])return r[0];if(a>=n[u])return r[u];for(var i=1;i<t&&!(n[i]>a||i===u);i++);var f=p(n[i-1],n[i],a),c=e?e[i-1](f):f;return o[i-1](c)}},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){B("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)},dn=a(function(n,r,t){var e=r-n;return((t-n)%e+e)%e+n}),ln=o(0,1),vn=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}},yn=function(n){return function(r){return Math.pow(r,n)}},gn=function(n){return function(r){return r*r*((n+1)*r-n)}},bn=function(n){var r=gn(n);return function(n){return(n*=2)<1?.5*r(n):.5*(2-Math.pow(2,-10*(n-1)))}},Mn=yn(2),xn=vn(Mn),wn=mn(Mn),On=function(n){return 1-Math.sin(Math.acos(n))},In=vn(On),Pn=mn(In),Fn=gn(1.525),An=vn(Fn),Rn=mn(Fn),Sn=bn(1.525),jn=8,kn=.001,En=1e-7,$n=10,zn=11,Dn=1/(zn-1),Un="undefined"!=typeof Float32Array,qn=function(n,r){return 1-3*r+3*n},Bn=function(n,r){return 3*r-6*n},Cn=function(n){return 3*n},Hn=function(n,r,t){return 3*qn(r,t)*n*n+2*Bn(r,t)*n+Cn(r)},Nn=function(n,r,t){return((qn(r,t)*n+Bn(r,t))*n+Cn(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.degreesToRadians=i,n.dilate=function(n,r,t){return n+(r-n)*t},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.isPoint=f,n.isPoint3D=c,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.velocityPerFrame=function(n,r){return e(n)?n/(1e3/r):0},n.velocityPerSecond=function(n,r){return r?n*(1e3/r):0},n.toDecimal=Q,n.wrap=dn,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 ln(u/n)}},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.smoothFrame=X,n.pipe=_,n.mixArray=G,n.mixColor=V,n.interpolate=function(n,r,t){var e,u,a,o,i=n.length;return 2===i&&"number"==typeof r[0]?(e=n[0],u=n[1],a=r[0],o=r[1],function(n){return(n-e)*(o-a)/(u-e)+a}):K(n,r,i,t)},n.conditional=function(n,r){return function(t){return n(t)?r(t):t}},n.mix=h,n.mixComplex=L,n.createAnticipateEasing=bn,n.createBackIn=gn,n.createExpoIn=yn,n.cubicBezier=function(n,r,t,e){var u=Un?new Float32Array(zn):new Array(zn),a=function(r){for(var e,a,o,i=0,f=1,c=zn-1;f!==c&&u[f]<=r;++f)i+=Dn;return e=(r-u[--f])/(u[f+1]-u[f]),(o=Hn(a=i+e*Dn,n,t))>=kn?function(r,e){for(var u=0,a=0;u<jn;++u){if(0===(a=Hn(e,n,t)))return e;e-=(Nn(e,n,t)-r)/a}return e}(r,a):0===o?a:function(r,e,u){var a,o,i=0;do{(a=Nn(o=e+(u-e)/2,n,t)-r)>0?u=o:e=o}while(Math.abs(a)>En&&++i<$n);return o}(r,i,i+Dn)};return function(){for(var r=0;r<zn;++r)u[r]=Nn(r*Dn,n,t)}(),function(u){return n===r&&t===e?u:0===u?0:1===u?1:Nn(a(u),r,e)}},n.linear=function(n){return n},n.easeIn=Mn,n.easeOut=xn,n.easeInOut=wn,n.circIn=On,n.circOut=In,n.circInOut=Pn,n.backIn=Fn,n.backOut=An,n.backInOut=Rn,n.anticipate=Sn,n.reversed=vn,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)}},y=function(n){return n%1?Number(n.toFixed(5)):n},g={test:function(n){return"number"==typeof n},parse:parseFloat,transform:function(n){return n}},b=(l({},g,{transform:v(0,1)}),l({},g,{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},F=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}},I=l({},g,{transform:function(n){return Math.round(M(n))}}),P=m("rgb"),A={test:function(n){return"string"==typeof n?P(n):w(n)},parse:F(["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:I.transform(r),green:I.transform(t),blue:I.transform(e),alpha:y(u)})}},R=m("hsl"),E={test:function(n){return"string"==typeof n?R(n):O(n)},parse:F(["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(y(t)),lightness:b.transform(y(e)),alpha:y(u)})}},S=l({},A,{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)||A.test(n)||E.test(n)||S.test(n)},k=function(n){return A.test(n)?A.parse(n):E.test(n)?E.parse(n):S.test(n)?S.parse(n):n},$=function(n){return w(n)?A.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,D=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(g.parse)),t},U=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]):y(n[a]));return e}},B=function(){};"production"!==process.env.NODE_ENV&&(B=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,A,E],T=function(n){return N.find(function(r){return r.test(n)})},V=function(n,r){var t=T(n),e=T(r);B(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: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=U(n);return B(t(n)===U(r)(n),"Values '"+n+"' and '"+r+"' are of different format, or a value might have changed value type."),_(L(D(n),D(r)),t)},J=a(h),K=function(n,r,t,e){var u=t-1;n[0]>n[u]&&(n.reverse(),r.reverse());var a,o=Array(u).fill("number"==typeof(a=r[0])?J:j(a)?V:G).map(function(n,t){return n(r[t],r[t+1])});return function(a){if(a<=n[0])return r[0];if(a>=n[u])return r[u];for(var i=1;i<t&&!(n[i]>a||i===u);i++);var f=p(n[i-1],n[i],a),c=e?e[i-1](f):f;return o[i-1](c)}},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){B("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)},dn=function(n){return n},ln=function(n){return void 0===n&&(n=dn),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=ln(),mn=ln(Math.sqrt),yn=a(function(n,r,t){var e=r-n;return((t-n)%e+e)%e+n}),gn=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)))}},Fn=xn(2),In=bn(Fn),Pn=Mn(Fn),An=function(n){return 1-Math.sin(Math.acos(n))},Rn=bn(An),En=Mn(Rn),Sn=wn(1.525),jn=bn(Sn),kn=Mn(Sn),$n=On(1.525),qn=8,zn=.001,Dn=1e-7,Un=10,Bn=11,Cn=1/(Bn-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.dilate=function(n,r,t){return n+(r-n)*t},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,u,a,o,i=n.length;return 2===i&&"number"==typeof r[0]?(e=n[0],u=n[1],a=r[0],o=r[1],function(n){return(n-e)*(o-a)/(u-e)+a}):K(n,r,i,t)},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=ln,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 gn(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=yn,n.createAnticipateEasing=On,n.createBackIn=wn,n.createExpoIn=xn,n.cubicBezier=function(n,r,t,e){var u=Hn?new Float32Array(Bn):new Array(Bn),a=function(r){for(var e,a,o,i=0,f=1,c=Bn-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)>Dn&&++i<Un);return o}(r,i,i+Cn)};return function(){for(var r=0;r<Bn;++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=Fn,n.easeOut=In,n.easeInOut=Pn,n.circIn=An,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})});

@@ -21,2 +21,3 @@ import angle from './utils/angle';

import snap from './utils/snap';
import { springForce, springForceLinear, springForceExpo } from './utils/spring-force';
import velocityPerFrame from './utils/velocity-per-frame';

@@ -28,2 +29,3 @@ import velocityPerSecond from './utils/velocity-per-second';

import { createAnticipateEasing, createBackIn, createExpoIn, cubicBezier, linear, easeIn, easeOut, easeInOut, circIn, circOut, circInOut, backIn, backOut, backInOut, anticipate, reversed, mirrored } from '@popmotion/easing';
export { angle, applyOffset, clamp, degreesToRadians, dilate, distance, isPoint, isPoint3D, pointFromVector, progress, radiansToDegrees, smooth, velocityPerFrame, velocityPerSecond, toDecimal, wrap, steps, snap, smoothFrame, pipe, mixArray, mixColor, interpolate, conditional, mix, mixComplex, createAnticipateEasing, createBackIn, createExpoIn, cubicBezier, linear, easeIn, easeOut, easeInOut, circIn, circOut, circInOut, backIn, backOut, backInOut, anticipate, reversed, mirrored };
export { angle, applyOffset, clamp, conditional, degreesToRadians, dilate, distance, interpolate, isPoint, isPoint3D, mix, mixArray, mixColor, mixComplex, pipe, pointFromVector, progress, radiansToDegrees, smooth, smoothFrame, snap, springForce, springForceExpo, springForceLinear, steps, toDecimal, velocityPerFrame, velocityPerSecond, wrap, createAnticipateEasing, createBackIn, createExpoIn, cubicBezier, linear, easeIn, easeOut, easeInOut, circIn, circOut, circInOut, backIn, backOut, backInOut, anticipate, reversed, mirrored };
export * from './types';

@@ -288,2 +288,16 @@ 'use strict';

var identity = function (v) { return v; };
var springForce = function (alterDisplacement) {
if (alterDisplacement === void 0) { alterDisplacement = identity; }
return curryRange(function (constant, origin, v) {
var displacement = origin - v;
var springModifiedDisplacement = -(0 - constant + 1) * (0 - alterDisplacement(Math.abs(displacement)));
return displacement <= 0
? origin + springModifiedDisplacement
: origin - springModifiedDisplacement;
});
};
var springForceLinear = springForce();
var springForceExpo = springForce(Math.sqrt);
var velocityPerFrame = (function (xps, frameDuration) {

@@ -335,7 +349,14 @@ return isNum(xps) ? xps / (1000 / frameDuration) : 0;

exports.clamp = clamp$1;
exports.conditional = conditional;
exports.degreesToRadians = degreesToRadians;
exports.dilate = dilate;
exports.distance = distance;
exports.interpolate = interpolate;
exports.isPoint = isPoint;
exports.isPoint3D = isPoint3D;
exports.mix = mix;
exports.mixArray = mixArray;
exports.mixColor = mixColor;
exports.mixComplex = mixComplex;
exports.pipe = pipe;
exports.pointFromVector = pointFromVector;

@@ -345,15 +366,11 @@ exports.progress = progress;

exports.smooth = smooth;
exports.smoothFrame = smoothFrame;
exports.snap = snap;
exports.springForce = springForce;
exports.springForceExpo = springForceExpo;
exports.springForceLinear = springForceLinear;
exports.steps = steps;
exports.toDecimal = toDecimal;
exports.velocityPerFrame = velocityPerFrame;
exports.velocityPerSecond = velocityPerSecond;
exports.toDecimal = toDecimal;
exports.wrap = wrap$1;
exports.steps = steps;
exports.snap = snap;
exports.smoothFrame = smoothFrame;
exports.pipe = pipe;
exports.mixArray = mixArray;
exports.mixColor = mixColor;
exports.interpolate = interpolate;
exports.conditional = conditional;
exports.mix = mix;
exports.mixComplex = mixComplex;
{
"name": "@popmotion/popcorn",
"version": "0.1.0",
"version": "0.1.1",
"description": "Utility functions for animation and interactions.",

@@ -37,5 +37,2 @@ "main": "lib/index.js",

"@types/jest": "^23.1.1",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-plugin-annotate-pure-calls": "^0.4.0",
"jest": "^23.1.0",

@@ -42,0 +39,0 @@ "jest-cli": "^23.1.0",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc