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

@motionone/generators

Package Overview
Dependencies
Maintainers
2
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@motionone/generators - npm Package Compare versions

Comparing version 10.6.1 to 10.6.2

5

dist/glide/index.cjs.js

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

target: from,
velocity: velocity$1,
};

@@ -44,4 +43,2 @@ const isOutOfBounds = (v) => (min !== undefined && v < min) || (max !== undefined && v > max);

state.current = state.done ? target : latest;
state.velocity =
t === 0 ? velocity$1 : velocity.calcGeneratorVelocity(calcLatest, t, state.current);
};

@@ -63,3 +60,3 @@ /**

to: nearestBoundary(state.current),
velocity: state.velocity,
velocity: velocity.calcGeneratorVelocity(calcLatest, t, state.current),
damping: bounceDamping,

@@ -66,0 +63,0 @@ stiffness: bounceStiffness,

@@ -12,3 +12,2 @@ import { time } from '@motionone/utils';

target: from,
velocity,
};

@@ -40,4 +39,2 @@ const isOutOfBounds = (v) => (min !== undefined && v < min) || (max !== undefined && v > max);

state.current = state.done ? target : latest;
state.velocity =
t === 0 ? velocity : calcGeneratorVelocity(calcLatest, t, state.current);
};

@@ -59,3 +56,3 @@ /**

to: nearestBoundary(state.current),
velocity: state.velocity,
velocity: calcGeneratorVelocity(calcLatest, t, state.current),
damping: bounceDamping,

@@ -62,0 +59,0 @@ stiffness: bounceStiffness,

2

dist/index.cjs.js

@@ -8,2 +8,3 @@ 'use strict';

var pregenerateKeyframes = require('./utils/pregenerate-keyframes.cjs.js');
var velocity = require('./utils/velocity.cjs.js');

@@ -15,1 +16,2 @@

exports.pregenerateKeyframes = pregenerateKeyframes.pregenerateKeyframes;
exports.calcGeneratorVelocity = velocity.calcGeneratorVelocity;
export { glide } from './glide/index.es.js';
export { spring } from './spring/index.es.js';
export { pregenerateKeyframes } from './utils/pregenerate-keyframes.es.js';
export { calcGeneratorVelocity } from './utils/velocity.es.js';

@@ -1,1 +0,1 @@

const t=t=>1e3*t,e=t=>t/1e3;function r(t,e,r){const a=Math.max(e-5,0);return n=r-t(a),(c=5)?n*(1e3/c):0;var n,c}const a=100,n=10,c=1;const s=({stiffness:t=a,damping:s=n,mass:o=c,from:i=0,to:h=1,velocity:d=0,restSpeed:u=2,restDistance:v=.5}={})=>{d=d?e(d):0;const M={done:!1,hasReachedTarget:!1,current:i,target:h,velocity:d},g=((t=a,e=n,r=c)=>e/(2*Math.sqrt(t*r)))(t,s,o),l=h-i,p=Math.sqrt(t/o)/1e3,f=((t,e)=>t*Math.sqrt(1-e*e))(p,g);let m;return m=g<1?t=>h-Math.exp(-g*p*t)*((g*p*l-d)/f*Math.sin(f*t)+l*Math.cos(f*t)):t=>h-Math.exp(-p*t)*(l+(d+p*l)*t),t=>{M.current=m(t),M.velocity=0===t?d:r(m,t,M.current);const e=Math.abs(M.velocity)<=u,a=Math.abs(h-M.current)<=v;var n,c,s;return M.done=e&&a,M.hasReachedTarget=(n=i,c=h,s=M.current,n<c&&s>=c||n>c&&s<=c),M}},o=({from:e=0,velocity:a=0,power:n=.8,decay:c=.325,bounceDamping:o,bounceStiffness:i,changeTarget:h,min:d,max:u,restDistance:v=.5,restSpeed:M})=>{c=t(c);const g={hasReachedTarget:!1,done:!1,current:e,target:e,velocity:a},l=t=>void 0===d?u:void 0===u||Math.abs(d-t)<Math.abs(u-t)?d:u;let p=n*a;const f=e+p,m=void 0===h?f:h(f);g.target=m,m!==f&&(p=m-e);const y=t=>-p*Math.exp(-t/c),b=t=>m+y(t),x=t=>{const e=y(t),n=b(t);g.done=Math.abs(e)<=v,g.current=g.done?m:n,g.velocity=0===t?a:r(b,t,g.current)};let T,R;const D=t=>{var e;(e=g.current,void 0!==d&&e<d||void 0!==u&&e>u)&&(T=t,R=s({from:g.current,to:l(g.current),velocity:g.velocity,damping:o,stiffness:i,restDistance:v,restSpeed:M}))};return D(0),t=>{let e=!1;return R||void 0!==T||(e=!0,x(t),D(t)),void 0!==T&&t>T?(g.hasReachedTarget=!0,R(t-T)):(g.hasReachedTarget=!1,!e&&x(t),g)}};export{o as glide};
const e=e=>1e3*e,t=e=>e/1e3;function r(e,t,r){const a=Math.max(t-5,0);return n=r-e(a),(s=t-a)?n*(1e3/s):0;var n,s}const a=100,n=10,s=1;const c=({stiffness:e=a,damping:c=n,mass:o=s,from:h=0,to:d=1,velocity:i=0,restSpeed:u=2,restDistance:M=.5}={})=>{i=i?t(i):0;const g={done:!1,hasReachedTarget:!1,current:h,target:d},v=d-h,f=Math.sqrt(e/o)/1e3,p=((e=a,t=n,r=s)=>t/(2*Math.sqrt(e*r)))(e,c,o);let m;if(p<1){const e=f*Math.sqrt(1-p*p);m=t=>d-Math.exp(-p*f*t)*((p*f*v-i)/e*Math.sin(e*t)+v*Math.cos(e*t))}else m=e=>d-Math.exp(-f*e)*(v+(f*v-i)*e);return e=>{g.current=m(e);const t=0===e?i:r(m,e,g.current),a=Math.abs(t)<=u,n=Math.abs(d-g.current)<=M;var s,c,o;return g.done=a&&n,g.hasReachedTarget=(s=h,c=d,o=g.current,s<c&&o>=c||s>c&&o<=c),g}},o=({from:t=0,velocity:a=0,power:n=.8,decay:s=.325,bounceDamping:o,bounceStiffness:h,changeTarget:d,min:i,max:u,restDistance:M=.5,restSpeed:g})=>{s=e(s);const v={hasReachedTarget:!1,done:!1,current:t,target:t},f=e=>void 0===i?u:void 0===u||Math.abs(i-e)<Math.abs(u-e)?i:u;let p=n*a;const m=t+p,l=void 0===d?m:d(m);v.target=l,l!==m&&(p=l-t);const b=e=>-p*Math.exp(-e/s),x=e=>l+b(e),T=e=>{const t=b(e),r=x(e);v.done=Math.abs(t)<=M,v.current=v.done?l:r};let R,y;const D=e=>{var t;(t=v.current,void 0!==i&&t<i||void 0!==u&&t>u)&&(R=e,y=c({from:v.current,to:f(v.current),velocity:r(x,e,v.current),damping:o,stiffness:h,restDistance:M,restSpeed:g}))};return D(0),e=>{let t=!1;return y||void 0!==R||(t=!0,T(e),D(e)),void 0!==R&&e>R?(v.hasReachedTarget=!0,y(e-R)):(v.hasReachedTarget=!1,!t&&T(e),v)}};export{o as glide};

@@ -1,1 +0,1 @@

const t=t=>t/1e3;const e=100,r=10,a=1;const s=({stiffness:s=e,damping:n=r,mass:c=a,from:o=0,to:h=1,velocity:M=0,restSpeed:i=2,restDistance:u=.5}={})=>{M=M?t(M):0;const d={done:!1,hasReachedTarget:!1,current:o,target:h,velocity:M},v=((t=e,s=r,n=a)=>s/(2*Math.sqrt(t*n)))(s,n,c),l=h-o,p=Math.sqrt(s/c)/1e3,f=((t,e)=>t*Math.sqrt(1-e*e))(p,v);let g;return g=v<1?t=>h-Math.exp(-v*p*t)*((v*p*l-M)/f*Math.sin(f*t)+l*Math.cos(f*t)):t=>h-Math.exp(-p*t)*(l+(M+p*l)*t),t=>{d.current=g(t),d.velocity=0===t?M:function(t,e,r){const a=Math.max(e-5,0);return s=r-t(a),(n=5)?s*(1e3/n):0;var s,n}(g,t,d.current);const e=Math.abs(d.velocity)<=i,r=Math.abs(h-d.current)<=u;var a,s,n;return d.done=e&&r,d.hasReachedTarget=(a=o,s=h,n=d.current,a<s&&n>=s||a>s&&n<=s),d}};export{s as spring};
const t=t=>t/1e3;const e=100,r=10,a=1;const s=({stiffness:s=e,damping:n=r,mass:c=a,from:o=0,to:h=1,velocity:M=0,restSpeed:u=2,restDistance:i=.5}={})=>{M=M?t(M):0;const d={done:!1,hasReachedTarget:!1,current:o,target:h},f=h-o,p=Math.sqrt(s/c)/1e3,g=((t=e,s=r,n=a)=>s/(2*Math.sqrt(t*n)))(s,n,c);let m;if(g<1){const t=p*Math.sqrt(1-g*g);m=e=>h-Math.exp(-g*p*e)*((g*p*f-M)/t*Math.sin(t*e)+f*Math.cos(t*e))}else m=t=>h-Math.exp(-p*t)*(f+(p*f-M)*t);return t=>{d.current=m(t);const e=0===t?M:function(t,e,r){const a=Math.max(e-5,0);return s=r-t(a),(n=e-a)?s*(1e3/n):0;var s,n}(m,t,d.current),r=Math.abs(e)<=u,a=Math.abs(h-d.current)<=i;var s,n,c;return d.done=r&&a,d.hasReachedTarget=(s=o,n=h,c=d.current,s<n&&c>=n||s>n&&c<=n),d}};export{s as spring};

@@ -18,10 +18,9 @@ 'use strict';

target: to,
velocity: velocity$1,
};
const dampingRatio = utils$1.calcDampingRatio(stiffness, damping, mass);
const initialDelta = to - from;
const undampedAngularFreq = Math.sqrt(stiffness / mass) / 1000;
const angularFreq = utils$1.calcAngularFreq(undampedAngularFreq, dampingRatio);
const dampingRatio = utils$1.calcDampingRatio(stiffness, damping, mass);
let resolveSpring;
if (dampingRatio < 1) {
const angularFreq = undampedAngularFreq * Math.sqrt(1 - dampingRatio * dampingRatio);
// Underdamped spring (bouncy)

@@ -37,13 +36,14 @@ resolveSpring = (t) => to -

// Critically damped spring
resolveSpring = (t) => to -
Math.exp(-undampedAngularFreq * t) *
(initialDelta + (velocity$1 + undampedAngularFreq * initialDelta) * t);
resolveSpring = (t) => {
return (to -
Math.exp(-undampedAngularFreq * t) *
(initialDelta + (-velocity$1 + undampedAngularFreq * initialDelta) * t));
};
}
return (t) => {
state.current = resolveSpring(t);
state.velocity =
t === 0
? velocity$1
: velocity.calcGeneratorVelocity(resolveSpring, t, state.current);
const isBelowVelocityThreshold = Math.abs(state.velocity) <= restSpeed;
const currentVelocity = t === 0
? velocity$1
: velocity.calcGeneratorVelocity(resolveSpring, t, state.current);
const isBelowVelocityThreshold = Math.abs(currentVelocity) <= restSpeed;
const isBelowDisplacementThreshold = Math.abs(to - state.current) <= restDistance;

@@ -50,0 +50,0 @@ state.done = isBelowVelocityThreshold && isBelowDisplacementThreshold;

import { time } from '@motionone/utils';
import { defaults } from './defaults.es.js';
import { calcDampingRatio, calcAngularFreq } from './utils.es.js';
import { calcDampingRatio } from './utils.es.js';
import { hasReachedTarget } from '../utils/has-reached-target.es.js';

@@ -14,10 +14,9 @@ import { calcGeneratorVelocity } from '../utils/velocity.es.js';

target: to,
velocity,
};
const dampingRatio = calcDampingRatio(stiffness, damping, mass);
const initialDelta = to - from;
const undampedAngularFreq = Math.sqrt(stiffness / mass) / 1000;
const angularFreq = calcAngularFreq(undampedAngularFreq, dampingRatio);
const dampingRatio = calcDampingRatio(stiffness, damping, mass);
let resolveSpring;
if (dampingRatio < 1) {
const angularFreq = undampedAngularFreq * Math.sqrt(1 - dampingRatio * dampingRatio);
// Underdamped spring (bouncy)

@@ -33,13 +32,14 @@ resolveSpring = (t) => to -

// Critically damped spring
resolveSpring = (t) => to -
Math.exp(-undampedAngularFreq * t) *
(initialDelta + (velocity + undampedAngularFreq * initialDelta) * t);
resolveSpring = (t) => {
return (to -
Math.exp(-undampedAngularFreq * t) *
(initialDelta + (-velocity + undampedAngularFreq * initialDelta) * t));
};
}
return (t) => {
state.current = resolveSpring(t);
state.velocity =
t === 0
? velocity
: calcGeneratorVelocity(resolveSpring, t, state.current);
const isBelowVelocityThreshold = Math.abs(state.velocity) <= restSpeed;
const currentVelocity = t === 0
? velocity
: calcGeneratorVelocity(resolveSpring, t, state.current);
const isBelowVelocityThreshold = Math.abs(currentVelocity) <= restSpeed;
const isBelowDisplacementThreshold = Math.abs(to - state.current) <= restDistance;

@@ -46,0 +46,0 @@ state.done = isBelowVelocityThreshold && isBelowDisplacementThreshold;

@@ -8,5 +8,3 @@ 'use strict';

const calcDampingRatio = (stiffness = defaults.defaults.stiffness, damping = defaults.defaults.damping, mass = defaults.defaults.mass) => damping / (2 * Math.sqrt(stiffness * mass));
const calcAngularFreq = (undampedFreq, dampingRatio) => undampedFreq * Math.sqrt(1 - dampingRatio * dampingRatio);
exports.calcAngularFreq = calcAngularFreq;
exports.calcDampingRatio = calcDampingRatio;
import { defaults } from './defaults.es.js';
const calcDampingRatio = (stiffness = defaults.stiffness, damping = defaults.damping, mass = defaults.mass) => damping / (2 * Math.sqrt(stiffness * mass));
const calcAngularFreq = (undampedFreq, dampingRatio) => undampedFreq * Math.sqrt(1 - dampingRatio * dampingRatio);
export { calcAngularFreq, calcDampingRatio };
export { calcDampingRatio };

@@ -10,5 +10,5 @@ 'use strict';

const prevT = Math.max(t - sampleT, 0);
return utils.velocityPerSecond(current - resolveValue(prevT), 5);
return utils.velocityPerSecond(current - resolveValue(prevT), t - prevT);
}
exports.calcGeneratorVelocity = calcGeneratorVelocity;

@@ -6,5 +6,5 @@ import { velocityPerSecond } from '@motionone/utils';

const prevT = Math.max(t - sampleT, 0);
return velocityPerSecond(current - resolveValue(prevT), 5);
return velocityPerSecond(current - resolveValue(prevT), t - prevT);
}
export { calcGeneratorVelocity };

@@ -11,3 +11,2 @@ import { time } from "@motionone/utils";

target: from,
velocity,
};

@@ -39,4 +38,2 @@ const isOutOfBounds = (v) => (min !== undefined && v < min) || (max !== undefined && v > max);

state.current = state.done ? target : latest;
state.velocity =
t === 0 ? velocity : calcGeneratorVelocity(calcLatest, t, state.current);
};

@@ -58,3 +55,3 @@ /**

to: nearestBoundary(state.current),
velocity: state.velocity,
velocity: calcGeneratorVelocity(calcLatest, t, state.current),
damping: bounceDamping,

@@ -61,0 +58,0 @@ stiffness: bounceStiffness,

export { glide } from "./glide/index.js";
export { spring } from "./spring/index.js";
export { pregenerateKeyframes } from "./utils/pregenerate-keyframes";
export { calcGeneratorVelocity } from "./utils/velocity";
export * from "./glide/types";
export * from "./spring/types";
//# sourceMappingURL=index.js.map
import { time } from "@motionone/utils";
import { defaults } from "./defaults";
import { calcAngularFreq, calcDampingRatio } from "./utils";
import { calcDampingRatio } from "./utils";
import { hasReachedTarget } from "../utils/has-reached-target";

@@ -13,10 +13,9 @@ import { calcGeneratorVelocity } from "../utils/velocity";

target: to,
velocity,
};
const dampingRatio = calcDampingRatio(stiffness, damping, mass);
const initialDelta = to - from;
const undampedAngularFreq = Math.sqrt(stiffness / mass) / 1000;
const angularFreq = calcAngularFreq(undampedAngularFreq, dampingRatio);
const dampingRatio = calcDampingRatio(stiffness, damping, mass);
let resolveSpring;
if (dampingRatio < 1) {
const angularFreq = undampedAngularFreq * Math.sqrt(1 - dampingRatio * dampingRatio);
// Underdamped spring (bouncy)

@@ -32,13 +31,14 @@ resolveSpring = (t) => to -

// Critically damped spring
resolveSpring = (t) => to -
Math.exp(-undampedAngularFreq * t) *
(initialDelta + (velocity + undampedAngularFreq * initialDelta) * t);
resolveSpring = (t) => {
return (to -
Math.exp(-undampedAngularFreq * t) *
(initialDelta + (-velocity + undampedAngularFreq * initialDelta) * t));
};
}
return (t) => {
state.current = resolveSpring(t);
state.velocity =
t === 0
? velocity
: calcGeneratorVelocity(resolveSpring, t, state.current);
const isBelowVelocityThreshold = Math.abs(state.velocity) <= restSpeed;
const currentVelocity = t === 0
? velocity
: calcGeneratorVelocity(resolveSpring, t, state.current);
const isBelowVelocityThreshold = Math.abs(currentVelocity) <= restSpeed;
const isBelowDisplacementThreshold = Math.abs(to - state.current) <= restDistance;

@@ -45,0 +45,0 @@ state.done = isBelowVelocityThreshold && isBelowDisplacementThreshold;

import { defaults } from "./defaults";
export const calcDampingRatio = (stiffness = defaults.stiffness, damping = defaults.damping, mass = defaults.mass) => damping / (2 * Math.sqrt(stiffness * mass));
export const calcAngularFreq = (undampedFreq, dampingRatio) => undampedFreq * Math.sqrt(1 - dampingRatio * dampingRatio);
//# sourceMappingURL=utils.js.map

@@ -5,4 +5,4 @@ import { velocityPerSecond } from "@motionone/utils";

const prevT = Math.max(t - sampleT, 0);
return velocityPerSecond(current - resolveValue(prevT), 5);
return velocityPerSecond(current - resolveValue(prevT), t - prevT);
}
//# sourceMappingURL=velocity.js.map
{
"name": "@motionone/generators",
"version": "10.6.1",
"version": "10.6.2",
"description": "A collection of animation generators.",

@@ -18,8 +18,8 @@ "license": "MIT",

"dependencies": {
"@motionone/types": "^10.6.1",
"@motionone/utils": "^10.6.1",
"@motionone/types": "^10.6.2",
"@motionone/utils": "^10.6.2",
"tslib": "^2.3.1"
},
"devDependencies": {
"@motionone/easing": "^10.6.1"
"@motionone/easing": "^10.6.2"
},

@@ -36,3 +36,3 @@ "bundlesize": [

],
"gitHead": "2d0605d1e1903b47ad20c6338588362371a3b6e5"
"gitHead": "b776bc7edd104b5545d2204713f7fb94eba50b21"
}
export { glide } from "./glide/index.js";
export { spring } from "./spring/index.js";
export { pregenerateKeyframes } from "./utils/pregenerate-keyframes";
export { calcGeneratorVelocity } from "./utils/velocity";
export type { KeyframesMetadata } from "./utils/pregenerate-keyframes";

@@ -5,0 +6,0 @@ export * from "./glide/types";

export declare const calcDampingRatio: (stiffness?: number, damping?: number, mass?: number) => number;
export declare const calcAngularFreq: (undampedFreq: number, dampingRatio: number) => number;
//# sourceMappingURL=utils.d.ts.map

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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