animazione
Advanced tools
Comparing version 0.2.4 to 0.2.5
@@ -84,3 +84,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
"use strict"; | ||
var _createClass=function(){function a(b,c){for(var e,d=0;d<c.length;d++)e=c[d],e.enumerable=e.enumerable||!1,e.configurable=!0,'value'in e&&(e.writable=!0),Object.defineProperty(b,e.key,e)}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}();function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError('Cannot call a class as a function')}var _require=__webpack_require__(2),raf=_require.raf,caf=_require.caf,TOLERANCE_THRESHOLD=0.25,noop=function(){},linearEasing=function(a){return a},Animazione=function(){function a(){var b=this,c=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};_classCallCheck(this,a);var d=c.render,e=void 0===d?noop:d,f=c.target,g=void 0===f?null:f,h=c.duration,j=void 0===h?0:h,k=c.initialValue,l=void 0===k?0:k,m=c.endValue,n=void 0===m?100:m,o=c.easing,p=void 0===o?linearEasing:o,q=c.fps,r=void 0===q?60:q,s=c.onComplete,u=void 0===s?noop:s,v=c.loop;this._opts=c,this._loop=void 0!==v&&v,this._animations=[{render:e,target:g,initialValue:l,endValue:n,duration:j,easing:p,fps:r,onComplete:u}],this._firstAnimation=this._animations.shift(),this._initializeAnimation(this._firstAnimation),this._tick=function(x){if(b._lastTime=x||0,(!b._lastTime||x>=b._nextTime-b._tolerance)&&(b._nextTime=b._lastTime+b._frameDuration,b._updateValue(),b._render(b._value),b._value===b._endValue)){if(0<b._animations.length){b._onComplete();var y=b._animations.shift();return b._initializeAnimation(y),b._loop&&b._animations.push(y),void(b._id=raf(b._tick))}return void b.stop()}b._id=raf(b._tick)}}return _createClass(a,[{key:'_initializeAnimation',value:function _initializeAnimation(b){var c=b.render,d=void 0===c?this._render:c,e=b.target,f=void 0===e?this._target:e,g=b.initialValue,h=void 0===g?0:g,j=b.endValue,k=void 0===j?0:j,l=b.duration,m=void 0===l?0:l,n=b.easing,o=void 0===n?this._opts.easing||linearEasing:n,p=b.fps,q=void 0===p?this._opts.fps||60:p,r=b.onComplete,s=void 0===r?noop:r;this._target=f,this._render=d.bind(f),this._onComplete=s.bind(f),this._initialValue=h,this._endValue=k,'function'==typeof o&&(this._easing=o),this._value=h,this._frameDuration=1e3/q,this._tolerance=this._frameDuration*TOLERANCE_THRESHOLD,this._framesCount=m/this._frameDuration,this._currentFrame=0,this._lastTime=0,this._delta=k-h}},{key:'_updateValue',value:function _updateValue(){if(this._currentFrame++,this._currentFrame>=this._framesCount)this._value=this._endValue;else{var b=this._initialValue+this._delta*this._easing(this._currentFrame/this._framesCount);this._value=b===this._endValue?this._endValue:b}}},{key:'start',value:function start(){return this._tick(),this}},{key:'andThen',value:function andThen(b){return this._animations.push(b),this}},{key:'wait',value:function wait(b){return this._animations.push({render:noop,duration:b,endValue:b}),this}},{key:'loop',value:function loop(){return this._animations.push(this._firstAnimation),this._loop=!0,this}},{key:'stop',value:function stop(){this._id&&caf(this._id)}}]),a}();module.exports=Animazione; | ||
var _createClass=function(){function a(b,c){for(var e,d=0;d<c.length;d++)e=c[d],e.enumerable=e.enumerable||!1,e.configurable=!0,'value'in e&&(e.writable=!0),Object.defineProperty(b,e.key,e)}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}();function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError('Cannot call a class as a function')}var _require=__webpack_require__(2),raf=_require.raf,caf=_require.caf,TOLERANCE_THRESHOLD=0.25,noop=function(){},linearEasing=function(a){return a},Animazione=function(){function a(){var b=this,c=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};_classCallCheck(this,a);var d=c.render,e=void 0===d?noop:d,f=c.target,g=void 0===f?null:f,h=c.duration,j=void 0===h?0:h,k=c.initialValue,l=void 0===k?0:k,m=c.endValue,n=void 0===m?100:m,o=c.easing,p=void 0===o?linearEasing:o,q=c.fps,r=void 0===q?60:q,s=c.onComplete,u=void 0===s?noop:s,v=c.loop;this._opts=c,this._loop=void 0!==v&&v,this._animations=[{render:e,target:g,initialValue:l,endValue:n,duration:j,easing:p,fps:r,onComplete:u}],this._firstAnimation=this._animations.shift(),this._initializeAnimation(this._firstAnimation),this._tick=function(x){if(b._lastTime=x||0,(!b._lastTime||x>=b._nextTime-b._tolerance)&&(b._nextTime=b._lastTime+b._frameDuration,b._updateValue(),b._render(b._value),b._value===b._endValue)){if(0<b._animations.length){b._onComplete();var y=b._animations.shift();return b._initializeAnimation(y),b._loop&&b._animations.push(y),void(b._id=raf(b._tick))}return b._onComplete(),void b.stop()}b._id=raf(b._tick)}}return _createClass(a,[{key:'_initializeAnimation',value:function _initializeAnimation(b){var c=b.render,d=void 0===c?this._render:c,e=b.target,f=void 0===e?this._target:e,g=b.initialValue,h=void 0===g?0:g,j=b.endValue,k=void 0===j?0:j,l=b.duration,m=void 0===l?0:l,n=b.easing,o=void 0===n?this._opts.easing||linearEasing:n,p=b.fps,q=void 0===p?this._opts.fps||60:p,r=b.onComplete,s=void 0===r?noop:r;this._target=f,this._render=d.bind(f),this._onComplete=s.bind(f),this._initialValue=h,this._endValue=k,'function'==typeof o&&(this._easing=o),this._value=h,this._frameDuration=1e3/q,this._tolerance=this._frameDuration*TOLERANCE_THRESHOLD,this._framesCount=m/this._frameDuration,this._currentFrame=0,this._lastTime=0,this._delta=k-h}},{key:'_updateValue',value:function _updateValue(){if(this._currentFrame++,this._currentFrame>=this._framesCount)this._value=this._endValue;else{var b=this._initialValue+this._delta*this._easing(this._currentFrame/this._framesCount);this._value=b===this._endValue?this._endValue:b}}},{key:'start',value:function start(){return this._tick(),this}},{key:'andThen',value:function andThen(b){return this._animations.push(b),this}},{key:'wait',value:function wait(b){return this._animations.push({render:noop,duration:b,endValue:b}),this}},{key:'loop',value:function loop(){return this._animations.push(this._firstAnimation),this._loop=!0,this}},{key:'stop',value:function stop(){this._id&&caf(this._id)}}]),a}();module.exports=Animazione; | ||
@@ -87,0 +87,0 @@ /***/ }), |
{ | ||
"name": "animazione", | ||
"version": "0.2.4", | ||
"version": "0.2.5", | ||
"description": "simple easing animations using requestAnimationFrame", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -51,2 +51,3 @@ const { raf, caf } = require('./request-animation-frame'); | ||
} | ||
this._onComplete(); | ||
this.stop(); | ||
@@ -53,0 +54,0 @@ return; |
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
11595
255