@motionone/animation
Advanced tools
Comparing version 10.13.1 to 10.13.2
@@ -1,1 +0,1 @@ | ||
const t=(t,e,i)=>Math.min(Math.max(i,t),e),e=.3,i=0,s=0,a=0,n="ease",r=t=>Array.isArray(t)&&!("number"==typeof t[0]);const h=(t,e,i)=>-i*t+i*e+t,o=t=>t,u=(t,e,i)=>e-t==0?1:(i-t)/(e-t);function l(t,e){const i=t[t.length-1];for(let s=1;s<=e;s++){const a=u(0,e,s);t.push(h(i,1,a))}}function c(e,i=function(t){const e=[0];return l(e,t-1),e}(e.length),s=o){const a=e.length,n=a-i.length;return n>0&&l(i,n),n=>{let o=0;for(;o<a-2&&!(n<i[o+1]);o++);let l=t(0,1,u(i[o],i[o+1],n));const c=function(t,e){return r(t)?t[((t,e,i)=>{const s=e-t;return((i-t)%s+s)%s+t})(0,t.length,e)]:t}(s,o);return l=c(l),h(e[o],e[o+1],l)}}const m=(t,e,i)=>(((1-3*i+3*e)*t+(3*i-6*e))*t+3*e)*t;function p(t,e,i,s){if(t===e&&i===s)return o;const a=e=>function(t,e,i,s,a){let n,r,h=0;do{r=e+(i-e)/2,n=m(r,s,a)-t,n>0?i=r:e=r}while(Math.abs(n)>1e-7&&++h<12);return r}(e,0,1,t,i);return t=>0===t||1===t?t:m(a(t),e,s)}const d={ease:p(.25,.1,.25,1),"ease-in":p(.42,0,1,1),"ease-in-out":p(.42,0,.58,1),"ease-out":p(0,0,.58,1)},f=/\((.*?)\)/;function y(e){if("function"==typeof e)return e;if(Array.isArray(e))return p(...e);if(d[e])return d[e];if(e.startsWith("steps")){const i=f.exec(e);if(i){const e=i[1].split(",");return((e,i="end")=>s=>{const a=(s="end"===i?Math.min(s,.999):Math.max(s,.001))*e,n="end"===i?Math.floor(a):Math.ceil(a);return t(0,1,n/e)})(parseFloat(e[0]),e[1].trim())}}return o}class T{constructor(t,h=[0,1],{easing:u,duration:l=e,delay:m=i,endDelay:p=s,repeat:d=a,offset:f,direction:T="normal"}={}){if(this.startTime=null,this.rate=1,this.t=0,this.cancelTimestamp=null,this.easing=o,this.duration=0,this.totalDuration=0,this.repeat=0,this.playState="idle",this.finished=new Promise(((t,e)=>{this.resolve=t,this.reject=e})),(t=>"object"==typeof t&&Boolean(t.createAnimation))(u=u||n)){const t=u.createAnimation(h,(()=>"0"),!0);u=t.easing,void 0!==t.keyframes&&(h=t.keyframes),void 0!==t.duration&&(l=t.duration)}this.repeat=d,this.easing=r(u)?o:y(u),this.updateDuration(l);const v=c(h,f,r(u)?u.map(y):o);this.tick=e=>{var i;let s=0;s=void 0!==this.pauseTime?this.pauseTime:(e-this.startTime)*this.rate,this.t=s,s/=1e3,s=Math.max(s-m,0),"finished"===this.playState&&void 0===this.pauseTime&&(s=this.totalDuration);const a=s/this.duration;let n=Math.floor(a),r=a%1;!r&&a>=1&&(r=1),1===r&&n--;const h=n%2;("reverse"===T||"alternate"===T&&h||"alternate-reverse"===T&&!h)&&(r=1-r);const o=s>=this.totalDuration?1:Math.min(r,1),u=v(this.easing(o));t(u);void 0===this.pauseTime&&("finished"===this.playState||s>=this.totalDuration+p)?(this.playState="finished",null===(i=this.resolve)||void 0===i||i.call(this,u)):"idle"!==this.playState&&(this.frameRequestId=requestAnimationFrame(this.tick))},this.play()}play(){const t=performance.now();this.playState="running",void 0!==this.pauseTime?this.startTime=t-this.pauseTime:this.startTime||(this.startTime=t),this.cancelTimestamp=this.startTime,this.pauseTime=void 0,this.frameRequestId=requestAnimationFrame(this.tick)}pause(){this.playState="paused",this.pauseTime=this.t}finish(){this.playState="finished",this.tick(0)}stop(){var t;this.playState="idle",void 0!==this.frameRequestId&&cancelAnimationFrame(this.frameRequestId),null===(t=this.reject)||void 0===t||t.call(this,!1)}cancel(){this.stop(),this.tick(this.cancelTimestamp)}reverse(){this.rate*=-1}commitStyles(){}updateDuration(t){this.duration=t,this.totalDuration=t*(this.repeat+1)}get currentTime(){return this.t}set currentTime(t){void 0!==this.pauseTime||0===this.rate?this.pauseTime=t:this.startTime=performance.now()-t/this.rate}get playbackRate(){return this.rate}set playbackRate(t){this.rate=t}}export{T as Animation,y as getEasingFunction}; | ||
const t=(t,e,i)=>Math.min(Math.max(i,t),e),e=.3,i=0,s=0,a=0,n="ease",r=t=>"number"==typeof t,h=t=>Array.isArray(t)&&!r(t[0]);const o=(t,e,i)=>-i*t+i*e+t,u=t=>t,l=(t,e,i)=>e-t==0?1:(i-t)/(e-t);function c(t,e){const i=t[t.length-1];for(let s=1;s<=e;s++){const a=l(0,e,s);t.push(o(i,1,a))}}function m(e,i=function(t){const e=[0];return c(e,t-1),e}(e.length),s=u){const a=e.length,n=a-i.length;return n>0&&c(i,n),n=>{let r=0;for(;r<a-2&&!(n<i[r+1]);r++);let u=t(0,1,l(i[r],i[r+1],n));const c=function(t,e){return h(t)?t[((t,e,i)=>{const s=e-t;return((i-t)%s+s)%s+t})(0,t.length,e)]:t}(s,r);return u=c(u),o(e[r],e[r+1],u)}}const p=(t,e,i)=>(((1-3*i+3*e)*t+(3*i-6*e))*t+3*e)*t;function d(t,e,i,s){if(t===e&&i===s)return u;const a=e=>function(t,e,i,s,a){let n,r,h=0;do{r=e+(i-e)/2,n=p(r,s,a)-t,n>0?i=r:e=r}while(Math.abs(n)>1e-7&&++h<12);return r}(e,0,1,t,i);return t=>0===t||1===t?t:p(a(t),e,s)}const f={ease:d(.25,.1,.25,1),"ease-in":d(.42,0,1,1),"ease-in-out":d(.42,0,.58,1),"ease-out":d(0,0,.58,1)},y=/\((.*?)\)/;function T(e){if("function"==typeof e)return e;var i;if(i=e,Array.isArray(i)&&r(i[0]))return d(...e);if(f[e])return f[e];if(e.startsWith("steps")){const i=y.exec(e);if(i){const e=i[1].split(",");return((e,i="end")=>s=>{const a=(s="end"===i?Math.min(s,.999):Math.max(s,.001))*e,n="end"===i?Math.floor(a):Math.ceil(a);return t(0,1,n/e)})(parseFloat(e[0]),e[1].trim())}}return u}class v{constructor(t,r=[0,1],{easing:o,duration:l=e,delay:c=i,endDelay:p=s,repeat:d=a,offset:f,direction:y="normal"}={}){if(this.startTime=null,this.rate=1,this.t=0,this.cancelTimestamp=null,this.easing=u,this.duration=0,this.totalDuration=0,this.repeat=0,this.playState="idle",this.finished=new Promise(((t,e)=>{this.resolve=t,this.reject=e})),(t=>"object"==typeof t&&Boolean(t.createAnimation))(o=o||n)){const t=o.createAnimation(r,(()=>"0"),!0);o=t.easing,void 0!==t.keyframes&&(r=t.keyframes),void 0!==t.duration&&(l=t.duration)}this.repeat=d,this.easing=h(o)?u:T(o),this.updateDuration(l);const v=m(r,f,h(o)?o.map(T):u);this.tick=e=>{var i;let s=0;s=void 0!==this.pauseTime?this.pauseTime:(e-this.startTime)*this.rate,this.t=s,s/=1e3,s=Math.max(s-c,0),"finished"===this.playState&&void 0===this.pauseTime&&(s=this.totalDuration);const a=s/this.duration;let n=Math.floor(a),r=a%1;!r&&a>=1&&(r=1),1===r&&n--;const h=n%2;("reverse"===y||"alternate"===y&&h||"alternate-reverse"===y&&!h)&&(r=1-r);const o=s>=this.totalDuration?1:Math.min(r,1),u=v(this.easing(o));t(u);void 0===this.pauseTime&&("finished"===this.playState||s>=this.totalDuration+p)?(this.playState="finished",null===(i=this.resolve)||void 0===i||i.call(this,u)):"idle"!==this.playState&&(this.frameRequestId=requestAnimationFrame(this.tick))},this.play()}play(){const t=performance.now();this.playState="running",void 0!==this.pauseTime?this.startTime=t-this.pauseTime:this.startTime||(this.startTime=t),this.cancelTimestamp=this.startTime,this.pauseTime=void 0,this.frameRequestId=requestAnimationFrame(this.tick)}pause(){this.playState="paused",this.pauseTime=this.t}finish(){this.playState="finished",this.tick(0)}stop(){var t;this.playState="idle",void 0!==this.frameRequestId&&cancelAnimationFrame(this.frameRequestId),null===(t=this.reject)||void 0===t||t.call(this,!1)}cancel(){this.stop(),this.tick(this.cancelTimestamp)}reverse(){this.rate*=-1}commitStyles(){}updateDuration(t){this.duration=t,this.totalDuration=t*(this.repeat+1)}get currentTime(){return this.t}set currentTime(t){void 0!==this.pauseTime||0===this.rate?this.pauseTime=t:this.startTime=performance.now()-t/this.rate}get playbackRate(){return this.rate}set playbackRate(t){this.rate=t}}export{v as Animation,T as getEasingFunction}; |
@@ -20,3 +20,3 @@ 'use strict'; | ||
// If an easing curve definition, return bezier function | ||
if (Array.isArray(definition)) | ||
if (utils.isCubicBezier(definition)) | ||
return easing.cubicBezier(...definition); | ||
@@ -23,0 +23,0 @@ // If we have a predefined easing function, return |
import { cubicBezier, steps } from '@motionone/easing'; | ||
import { isFunction, noopReturn } from '@motionone/utils'; | ||
import { isFunction, isCubicBezier, noopReturn } from '@motionone/utils'; | ||
@@ -16,3 +16,3 @@ const namedEasings = { | ||
// If an easing curve definition, return bezier function | ||
if (Array.isArray(definition)) | ||
if (isCubicBezier(definition)) | ||
return cubicBezier(...definition); | ||
@@ -19,0 +19,0 @@ // If we have a predefined easing function, return |
import { cubicBezier, steps } from "@motionone/easing"; | ||
import { noopReturn, isFunction } from "@motionone/utils"; | ||
import { noopReturn, isFunction, isCubicBezier } from "@motionone/utils"; | ||
const namedEasings = { | ||
@@ -15,3 +15,3 @@ ease: cubicBezier(0.25, 0.1, 0.25, 1.0), | ||
// If an easing curve definition, return bezier function | ||
if (Array.isArray(definition)) | ||
if (isCubicBezier(definition)) | ||
return cubicBezier(...definition); | ||
@@ -18,0 +18,0 @@ // If we have a predefined easing function, return |
{ | ||
"name": "@motionone/animation", | ||
"version": "10.13.1", | ||
"version": "10.13.2", | ||
"description": "A semi-polyfill WAAPI animation.", | ||
@@ -18,5 +18,5 @@ "license": "MIT", | ||
"dependencies": { | ||
"@motionone/easing": "^10.13.1", | ||
"@motionone/types": "^10.13.0", | ||
"@motionone/utils": "^10.13.1", | ||
"@motionone/easing": "^10.13.2", | ||
"@motionone/types": "^10.13.2", | ||
"@motionone/utils": "^10.13.2", | ||
"tslib": "^2.3.1" | ||
@@ -30,3 +30,3 @@ }, | ||
], | ||
"gitHead": "ddaaf9ddc461760f8ebdca38b12f5049e1b92953" | ||
"gitHead": "a33ab88400c8aac4a6755cda6f93c24563d9ddc5" | ||
} |
Sorry, the diff of this file is not supported yet
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
37217
638
Updated@motionone/easing@^10.13.2
Updated@motionone/types@^10.13.2
Updated@motionone/utils@^10.13.2