react-tween-state
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -5,2 +5,7 @@ Legend: | ||
### 0.1.4 (November 21th 2015) | ||
- [I] Support for IE9 through `requestAnimationFrame` polyfill. a0b4fb5. | ||
- [I] Used to use `this.isMounted()` internally. Removed that since React might deprecate this. #49. | ||
- [F] If duration's 0, we jump to `config.endValue` immediately, rather than calling the easing function. #52. | ||
### 0.1.3 (July 4th 2015) | ||
@@ -7,0 +12,0 @@ - [I] Export everything as default. |
518
lib/index.js
@@ -1,517 +0,1 @@ | ||
(function webpackUniversalModuleDefinition(root, factory) { | ||
if(typeof exports === 'object' && typeof module === 'object') | ||
module.exports = factory(); | ||
else if(typeof define === 'function' && define.amd) | ||
define(factory); | ||
else if(typeof exports === 'object') | ||
exports["tweenState"] = factory(); | ||
else | ||
root["tweenState"] = factory(); | ||
})(this, function() { | ||
return /******/ (function(modules) { // webpackBootstrap | ||
/******/ // The module cache | ||
/******/ var installedModules = {}; | ||
/******/ | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ | ||
/******/ // Check if module is in cache | ||
/******/ if(installedModules[moduleId]) | ||
/******/ return installedModules[moduleId].exports; | ||
/******/ | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = installedModules[moduleId] = { | ||
/******/ exports: {}, | ||
/******/ id: moduleId, | ||
/******/ loaded: false | ||
/******/ }; | ||
/******/ | ||
/******/ // Execute the module function | ||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
/******/ | ||
/******/ // Flag the module as loaded | ||
/******/ module.loaded = true; | ||
/******/ | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ | ||
/******/ | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = modules; | ||
/******/ | ||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = installedModules; | ||
/******/ | ||
/******/ // __webpack_public_path__ | ||
/******/ __webpack_require__.p = ""; | ||
/******/ | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(0); | ||
/******/ }) | ||
/************************************************************************/ | ||
/******/ ({ | ||
/***/ 0: | ||
/*!*****************!*\ | ||
!*** multi lib ***! | ||
\*****************/ | ||
/***/ function(module, exports, __webpack_require__) { | ||
module.exports = __webpack_require__(/*! ./index.js */160); | ||
/***/ }, | ||
/***/ 160: | ||
/*!******************!*\ | ||
!*** ./index.js ***! | ||
\******************/ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _tweenFunctions = __webpack_require__(/*! tween-functions */ 161); | ||
var _tweenFunctions2 = _interopRequireDefault(_tweenFunctions); | ||
// additive is the new iOS 8 default. In most cases it simulates a physics- | ||
// looking overshoot behavior (especially with easeInOut. You can test that in | ||
// the example | ||
var DEFAULT_STACK_BEHAVIOR = 'ADDITIVE'; | ||
var DEFAULT_EASING = _tweenFunctions.easeInOutQuad; | ||
var DEFAULT_DURATION = 300; | ||
var DEFAULT_DELAY = 0; | ||
var stackBehavior = { | ||
ADDITIVE: 'ADDITIVE', | ||
DESTRUCTIVE: 'DESTRUCTIVE' | ||
}; | ||
var Mixin = { | ||
getInitialState: function getInitialState() { | ||
return { | ||
tweenQueue: [] | ||
}; | ||
}, | ||
tweenState: function tweenState(path, _ref) { | ||
var _this = this; | ||
var easing = _ref.easing; | ||
var duration = _ref.duration; | ||
var delay = _ref.delay; | ||
var beginValue = _ref.beginValue; | ||
var endValue = _ref.endValue; | ||
var onEnd = _ref.onEnd; | ||
var configSB = _ref.stackBehavior; | ||
this.setState(function (state) { | ||
var cursor = state; | ||
var stateName = undefined; | ||
// see comment below on pash hash | ||
var pathHash = undefined; | ||
if (typeof path === 'string') { | ||
stateName = path; | ||
pathHash = path; | ||
} else { | ||
for (var i = 0; i < path.length - 1; i++) { | ||
cursor = cursor[path[i]]; | ||
} | ||
stateName = path[path.length - 1]; | ||
pathHash = path.join('|'); | ||
} | ||
// see the reasoning for these defaults at the top of file | ||
var newConfig = { | ||
easing: easing || DEFAULT_EASING, | ||
duration: duration == null ? DEFAULT_DURATION : duration, | ||
delay: delay == null ? DEFAULT_DELAY : delay, | ||
beginValue: beginValue == null ? cursor[stateName] : beginValue, | ||
endValue: endValue, | ||
onEnd: onEnd, | ||
stackBehavior: configSB || DEFAULT_STACK_BEHAVIOR | ||
}; | ||
var newTweenQueue = state.tweenQueue; | ||
if (newConfig.stackBehavior === stackBehavior.DESTRUCTIVE) { | ||
newTweenQueue = state.tweenQueue.filter(function (item) { | ||
return item.pathHash !== pathHash; | ||
}); | ||
} | ||
// we store path hash, so that during value retrieval we can use hash | ||
// comparison to find the path. See the kind of shitty thing you have to | ||
// do when you don't have value comparison for collections? | ||
newTweenQueue.push({ | ||
pathHash: pathHash, | ||
config: newConfig, | ||
initTime: Date.now() + newConfig.delay | ||
}); | ||
// sorry for mutating. For perf reasons we don't want to deep clone. | ||
// guys, can we please all start using persistent collections so that | ||
// we can stop worrying about nonesense like this | ||
cursor[stateName] = newConfig.endValue; | ||
if (newTweenQueue.length === 1) { | ||
_this.startRaf(); | ||
} | ||
// this will also include the above mutated update | ||
return { tweenQueue: newTweenQueue }; | ||
}); | ||
}, | ||
getTweeningValue: function getTweeningValue(path) { | ||
var state = this.state; | ||
var tweeningValue = undefined; | ||
var pathHash = undefined; | ||
if (typeof path === 'string') { | ||
tweeningValue = state[path]; | ||
pathHash = path; | ||
} else { | ||
tweeningValue = state; | ||
for (var i = 0; i < path.length; i++) { | ||
tweeningValue = tweeningValue[path[i]]; | ||
} | ||
pathHash = path.join('|'); | ||
} | ||
var now = Date.now(); | ||
for (var i = 0; i < state.tweenQueue.length; i++) { | ||
var item = state.tweenQueue[i]; | ||
if (item.pathHash !== pathHash) { | ||
continue; | ||
} | ||
var progressTime = now - item.initTime > item.config.duration ? item.config.duration : Math.max(0, now - item.initTime); | ||
// `now - item.initTime` can be negative if initTime is scheduled in the | ||
// future by a delay. In this case we take 0 | ||
var contrib = -item.config.endValue + item.config.easing(progressTime, item.config.beginValue, item.config.endValue, item.config.duration); | ||
tweeningValue += contrib; | ||
} | ||
return tweeningValue; | ||
}, | ||
_rafCb: function _rafCb() { | ||
var state = this.state; | ||
if (state.tweenQueue.length === 0) { | ||
return; | ||
} | ||
var now = Date.now(); | ||
var newTweenQueue = []; | ||
for (var i = 0; i < state.tweenQueue.length; i++) { | ||
var item = state.tweenQueue[i]; | ||
if (now - item.initTime < item.config.duration) { | ||
newTweenQueue.push(item); | ||
} else { | ||
item.config.onEnd && item.config.onEnd(); | ||
} | ||
} | ||
// onEnd might trigger a parent callback that removes this component | ||
if (!this.isMounted()) { | ||
return; | ||
} | ||
this.setState({ | ||
tweenQueue: newTweenQueue | ||
}); | ||
requestAnimationFrame(this._rafCb); | ||
}, | ||
startRaf: function startRaf() { | ||
requestAnimationFrame(this._rafCb); | ||
} | ||
}; | ||
exports['default'] = { | ||
Mixin: Mixin, | ||
easingTypes: _tweenFunctions2['default'], | ||
stackBehavior: stackBehavior | ||
}; | ||
module.exports = exports['default']; | ||
// TODO: some funcs accept a 5th param | ||
/***/ }, | ||
/***/ 161: | ||
/*!************************************!*\ | ||
!*** ./~/tween-functions/index.js ***! | ||
\************************************/ | ||
/***/ function(module, exports) { | ||
'use strict'; | ||
// t: current time, b: beginning value, _c: final value, d: total duration | ||
var tweenFunctions = { | ||
linear: function(t, b, _c, d) { | ||
var c = _c - b; | ||
return c * t / d + b; | ||
}, | ||
easeInQuad: function(t, b, _c, d) { | ||
var c = _c - b; | ||
return c * (t /= d) * t + b; | ||
}, | ||
easeOutQuad: function(t, b, _c, d) { | ||
var c = _c - b; | ||
return -c * (t /= d) * (t - 2) + b; | ||
}, | ||
easeInOutQuad: function(t, b, _c, d) { | ||
var c = _c - b; | ||
if ((t /= d / 2) < 1) { | ||
return c / 2 * t * t + b; | ||
} else { | ||
return -c / 2 * ((--t) * (t - 2) - 1) + b; | ||
} | ||
}, | ||
easeInCubic: function(t, b, _c, d) { | ||
var c = _c - b; | ||
return c * (t /= d) * t * t + b; | ||
}, | ||
easeOutCubic: function(t, b, _c, d) { | ||
var c = _c - b; | ||
return c * ((t = t / d - 1) * t * t + 1) + b; | ||
}, | ||
easeInOutCubic: function(t, b, _c, d) { | ||
var c = _c - b; | ||
if ((t /= d / 2) < 1) { | ||
return c / 2 * t * t * t + b; | ||
} else { | ||
return c / 2 * ((t -= 2) * t * t + 2) + b; | ||
} | ||
}, | ||
easeInQuart: function(t, b, _c, d) { | ||
var c = _c - b; | ||
return c * (t /= d) * t * t * t + b; | ||
}, | ||
easeOutQuart: function(t, b, _c, d) { | ||
var c = _c - b; | ||
return -c * ((t = t / d - 1) * t * t * t - 1) + b; | ||
}, | ||
easeInOutQuart: function(t, b, _c, d) { | ||
var c = _c - b; | ||
if ((t /= d / 2) < 1) { | ||
return c / 2 * t * t * t * t + b; | ||
} else { | ||
return -c / 2 * ((t -= 2) * t * t * t - 2) + b; | ||
} | ||
}, | ||
easeInQuint: function(t, b, _c, d) { | ||
var c = _c - b; | ||
return c * (t /= d) * t * t * t * t + b; | ||
}, | ||
easeOutQuint: function(t, b, _c, d) { | ||
var c = _c - b; | ||
return c * ((t = t / d - 1) * t * t * t * t + 1) + b; | ||
}, | ||
easeInOutQuint: function(t, b, _c, d) { | ||
var c = _c - b; | ||
if ((t /= d / 2) < 1) { | ||
return c / 2 * t * t * t * t * t + b; | ||
} else { | ||
return c / 2 * ((t -= 2) * t * t * t * t + 2) + b; | ||
} | ||
}, | ||
easeInSine: function(t, b, _c, d) { | ||
var c = _c - b; | ||
return -c * Math.cos(t / d * (Math.PI / 2)) + c + b; | ||
}, | ||
easeOutSine: function(t, b, _c, d) { | ||
var c = _c - b; | ||
return c * Math.sin(t / d * (Math.PI / 2)) + b; | ||
}, | ||
easeInOutSine: function(t, b, _c, d) { | ||
var c = _c - b; | ||
return -c / 2 * (Math.cos(Math.PI * t / d) - 1) + b; | ||
}, | ||
easeInExpo: function(t, b, _c, d) { | ||
var c = _c - b; | ||
var _ref; | ||
return (_ref = t === 0) !== null ? _ref : { | ||
b: c * Math.pow(2, 10 * (t / d - 1)) + b | ||
}; | ||
}, | ||
easeOutExpo: function(t, b, _c, d) { | ||
var c = _c - b; | ||
var _ref; | ||
return (_ref = t === d) !== null ? _ref : b + { | ||
c: c * (-Math.pow(2, -10 * t / d) + 1) + b | ||
}; | ||
}, | ||
easeInOutExpo: function(t, b, _c, d) { | ||
var c = _c - b; | ||
if (t === 0) { | ||
b; | ||
} | ||
if (t === d) { | ||
b + c; | ||
} | ||
if ((t /= d / 2) < 1) { | ||
return c / 2 * Math.pow(2, 10 * (t - 1)) + b; | ||
} else { | ||
return c / 2 * (-Math.pow(2, -10 * --t) + 2) + b; | ||
} | ||
}, | ||
easeInCirc: function(t, b, _c, d) { | ||
var c = _c - b; | ||
return -c * (Math.sqrt(1 - (t /= d) * t) - 1) + b; | ||
}, | ||
easeOutCirc: function(t, b, _c, d) { | ||
var c = _c - b; | ||
return c * Math.sqrt(1 - (t = t / d - 1) * t) + b; | ||
}, | ||
easeInOutCirc: function(t, b, _c, d) { | ||
var c = _c - b; | ||
if ((t /= d / 2) < 1) { | ||
return -c / 2 * (Math.sqrt(1 - t * t) - 1) + b; | ||
} else { | ||
return c / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + b; | ||
} | ||
}, | ||
easeInElastic: function(t, b, _c, d) { | ||
var c = _c - b; | ||
var a, p, s; | ||
s = 1.70158; | ||
p = 0; | ||
a = c; | ||
if (t === 0) { | ||
b; | ||
} else if ((t /= d) === 1) { | ||
b + c; | ||
} | ||
if (!p) { | ||
p = d * 0.3; | ||
} | ||
if (a < Math.abs(c)) { | ||
a = c; | ||
s = p / 4; | ||
} else { | ||
s = p / (2 * Math.PI) * Math.asin(c / a); | ||
} | ||
return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b; | ||
}, | ||
easeOutElastic: function(t, b, _c, d) { | ||
var c = _c - b; | ||
var a, p, s; | ||
s = 1.70158; | ||
p = 0; | ||
a = c; | ||
if (t === 0) { | ||
b; | ||
} else if ((t /= d) === 1) { | ||
b + c; | ||
} | ||
if (!p) { | ||
p = d * 0.3; | ||
} | ||
if (a < Math.abs(c)) { | ||
a = c; | ||
s = p / 4; | ||
} else { | ||
s = p / (2 * Math.PI) * Math.asin(c / a); | ||
} | ||
return a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b; | ||
}, | ||
easeInOutElastic: function(t, b, _c, d) { | ||
var c = _c - b; | ||
var a, p, s; | ||
s = 1.70158; | ||
p = 0; | ||
a = c; | ||
if (t === 0) { | ||
b; | ||
} else if ((t /= d / 2) === 2) { | ||
b + c; | ||
} | ||
if (!p) { | ||
p = d * (0.3 * 1.5); | ||
} | ||
if (a < Math.abs(c)) { | ||
a = c; | ||
s = p / 4; | ||
} else { | ||
s = p / (2 * Math.PI) * Math.asin(c / a); | ||
} | ||
if (t < 1) { | ||
return -0.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b; | ||
} else { | ||
return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p) * 0.5 + c + b; | ||
} | ||
}, | ||
easeInBack: function(t, b, _c, d, s) { | ||
var c = _c - b; | ||
if (s === void 0) { | ||
s = 1.70158; | ||
} | ||
return c * (t /= d) * t * ((s + 1) * t - s) + b; | ||
}, | ||
easeOutBack: function(t, b, _c, d, s) { | ||
var c = _c - b; | ||
if (s === void 0) { | ||
s = 1.70158; | ||
} | ||
return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b; | ||
}, | ||
easeInOutBack: function(t, b, _c, d, s) { | ||
var c = _c - b; | ||
if (s === void 0) { | ||
s = 1.70158; | ||
} | ||
if ((t /= d / 2) < 1) { | ||
return c / 2 * (t * t * (((s *= 1.525) + 1) * t - s)) + b; | ||
} else { | ||
return c / 2 * ((t -= 2) * t * (((s *= 1.525) + 1) * t + s) + 2) + b; | ||
} | ||
}, | ||
easeInBounce: function(t, b, _c, d) { | ||
var c = _c - b; | ||
var v; | ||
v = tweenFunctions.easeOutBounce(d - t, 0, c, d); | ||
return c - v + b; | ||
}, | ||
easeOutBounce: function(t, b, _c, d) { | ||
var c = _c - b; | ||
if ((t /= d) < 1 / 2.75) { | ||
return c * (7.5625 * t * t) + b; | ||
} else if (t < 2 / 2.75) { | ||
return c * (7.5625 * (t -= 1.5 / 2.75) * t + 0.75) + b; | ||
} else if (t < 2.5 / 2.75) { | ||
return c * (7.5625 * (t -= 2.25 / 2.75) * t + 0.9375) + b; | ||
} else { | ||
return c * (7.5625 * (t -= 2.625 / 2.75) * t + 0.984375) + b; | ||
} | ||
}, | ||
easeInOutBounce: function(t, b, _c, d) { | ||
var c = _c - b; | ||
var v; | ||
if (t < d / 2) { | ||
v = tweenFunctions.easeInBounce(t * 2, 0, c, d); | ||
return v * 0.5 + b; | ||
} else { | ||
v = tweenFunctions.easeOutBounce(t * 2 - d, 0, c, d); | ||
return v * 0.5 + c * 0.5 + b; | ||
} | ||
} | ||
}; | ||
module.exports = tweenFunctions; | ||
/***/ } | ||
/******/ }) | ||
}); | ||
; | ||
//# sourceMappingURL=index.js.map | ||
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.tweenState=n():e.tweenState=n()}(this,function(){return function(e){function n(r){if(t[r])return t[r].exports;var a=t[r]={exports:{},id:r,loaded:!1};return e[r].call(a.exports,a,a.exports,n),a.loaded=!0,a.exports}var t={};return n.m=e,n.c=t,n.p="",n(0)}({0:function(e,n,t){e.exports=t(90)},1:function(e,n){function t(){c=!1,o.length?s=o.concat(s):f=-1,s.length&&r()}function r(){if(!c){var e=setTimeout(t);c=!0;for(var n=s.length;n;){for(o=s,s=[];++f<n;)o&&o[f].run();f=-1,n=s.length}o=null,c=!1,clearTimeout(e)}}function a(e,n){this.fun=e,this.array=n}function u(){}var o,i=e.exports={},s=[],c=!1,f=-1;i.nextTick=function(e){var n=new Array(arguments.length-1);if(arguments.length>1)for(var t=1;t<arguments.length;t++)n[t-1]=arguments[t];s.push(new a(e,n)),1!==s.length||c||setTimeout(r,0)},a.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=u,i.addListener=u,i.once=u,i.off=u,i.removeListener=u,i.removeAllListeners=u,i.emit=u,i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},90:function(e,n,t){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var a=t(165),u=r(a),o=t(91),i=r(o),s="ADDITIVE",c=a.easeInOutQuad,f=300,l=0,h={ADDITIVE:"ADDITIVE",DESTRUCTIVE:"DESTRUCTIVE"},v={_rafID:null,getInitialState:function(){return{tweenQueue:[]}},componentWillUnmount:function(){i["default"].cancel(this._rafID),this._rafID=-1},tweenState:function(e,n){var t=this,r=n.easing,a=n.duration,u=n.delay,o=n.beginValue,v=n.endValue,d=n.onEnd,p=n.stackBehavior;this.setState(function(n){var I=n,w=void 0,g=void 0;if("string"==typeof e)w=e,g=e;else{for(var M=0;M<e.length-1;M++)I=I[e[M]];w=e[e.length-1],g=e.join("|")}var m={easing:r||c,duration:null==a?f:a,delay:null==u?l:u,beginValue:null==o?I[w]:o,endValue:v,onEnd:d,stackBehavior:p||s},x=n.tweenQueue;return m.stackBehavior===h.DESTRUCTIVE&&(x=n.tweenQueue.filter(function(e){return e.pathHash!==g})),x.push({pathHash:g,config:m,initTime:Date.now()+m.delay}),I[w]=m.endValue,1===x.length&&(t._rafID=(0,i["default"])(t._rafCb)),{tweenQueue:x}})},getTweeningValue:function(e){var n=this.state,t=void 0,r=void 0;if("string"==typeof e)t=n[e],r=e;else{t=n;for(var a=0;a<e.length;a++)t=t[e[a]];r=e.join("|")}for(var u=Date.now(),a=0;a<n.tweenQueue.length;a++){var o=n.tweenQueue[a],i=o.pathHash,s=o.initTime,c=o.config;if(i===r){var f=u-s>c.duration?c.duration:Math.max(0,u-s),l=0===c.duration?c.endValue:c.easing(f,c.beginValue,c.endValue,c.duration),h=l-c.endValue;t+=h}}return t},_rafCb:function(){var e=this.state;if(0!==e.tweenQueue.length){for(var n=Date.now(),t=[],r=0;r<e.tweenQueue.length;r++){var a=e.tweenQueue[r],u=a.initTime,o=a.config;n-u<o.duration?t.push(a):o.onEnd&&o.onEnd()}-1!==this._rafID&&(this.setState({tweenQueue:t}),this._rafID=(0,i["default"])(this._rafCb))}}};n["default"]={Mixin:v,easingTypes:u["default"],stackBehavior:h},e.exports=n["default"]},91:function(e,n,t){for(var r=t(92),a="undefined"==typeof window?{}:window,u=["moz","webkit"],o="AnimationFrame",i=a["request"+o],s=a["cancel"+o]||a["cancelRequest"+o],c=0;c<u.length&&!i;c++)i=a[u[c]+"Request"+o],s=a[u[c]+"Cancel"+o]||a[u[c]+"CancelRequest"+o];if(!i||!s){var f=0,l=0,h=[],v=1e3/60;i=function(e){if(0===h.length){var n=r(),t=Math.max(0,v-(n-f));f=t+n,setTimeout(function(){var e=h.slice(0);h.length=0;for(var n=0;n<e.length;n++)if(!e[n].cancelled)try{e[n].callback(f)}catch(t){setTimeout(function(){throw t},0)}},Math.round(t))}return h.push({handle:++l,callback:e,cancelled:!1}),l},s=function(e){for(var n=0;n<h.length;n++)h[n].handle===e&&(h[n].cancelled=!0)}}e.exports=function(e){return i.call(a,e)},e.exports.cancel=function(){s.apply(a,arguments)}},92:function(e,n,t){(function(n){(function(){var t,r,a;"undefined"!=typeof performance&&null!==performance&&performance.now?e.exports=function(){return performance.now()}:"undefined"!=typeof n&&null!==n&&n.hrtime?(e.exports=function(){return(t()-a)/1e6},r=n.hrtime,t=function(){var e;return e=r(),1e9*e[0]+e[1]},a=t()):Date.now?(e.exports=function(){return Date.now()-a},a=Date.now()):(e.exports=function(){return(new Date).getTime()-a},a=(new Date).getTime())}).call(this)}).call(n,t(1))},165:function(e,n){"use strict";var t={linear:function(e,n,t,r){var a=t-n;return a*e/r+n},easeInQuad:function(e,n,t,r){var a=t-n;return a*(e/=r)*e+n},easeOutQuad:function(e,n,t,r){var a=t-n;return-a*(e/=r)*(e-2)+n},easeInOutQuad:function(e,n,t,r){var a=t-n;return(e/=r/2)<1?a/2*e*e+n:-a/2*(--e*(e-2)-1)+n},easeInCubic:function(e,n,t,r){var a=t-n;return a*(e/=r)*e*e+n},easeOutCubic:function(e,n,t,r){var a=t-n;return a*((e=e/r-1)*e*e+1)+n},easeInOutCubic:function(e,n,t,r){var a=t-n;return(e/=r/2)<1?a/2*e*e*e+n:a/2*((e-=2)*e*e+2)+n},easeInQuart:function(e,n,t,r){var a=t-n;return a*(e/=r)*e*e*e+n},easeOutQuart:function(e,n,t,r){var a=t-n;return-a*((e=e/r-1)*e*e*e-1)+n},easeInOutQuart:function(e,n,t,r){var a=t-n;return(e/=r/2)<1?a/2*e*e*e*e+n:-a/2*((e-=2)*e*e*e-2)+n},easeInQuint:function(e,n,t,r){var a=t-n;return a*(e/=r)*e*e*e*e+n},easeOutQuint:function(e,n,t,r){var a=t-n;return a*((e=e/r-1)*e*e*e*e+1)+n},easeInOutQuint:function(e,n,t,r){var a=t-n;return(e/=r/2)<1?a/2*e*e*e*e*e+n:a/2*((e-=2)*e*e*e*e+2)+n},easeInSine:function(e,n,t,r){var a=t-n;return-a*Math.cos(e/r*(Math.PI/2))+a+n},easeOutSine:function(e,n,t,r){var a=t-n;return a*Math.sin(e/r*(Math.PI/2))+n},easeInOutSine:function(e,n,t,r){var a=t-n;return-a/2*(Math.cos(Math.PI*e/r)-1)+n},easeInExpo:function(e,n,t,r){var a=t-n;return 0==e?n:a*Math.pow(2,10*(e/r-1))+n},easeOutExpo:function(e,n,t,r){var a=t-n;return e==r?n+a:a*(-Math.pow(2,-10*e/r)+1)+n},easeInOutExpo:function(e,n,t,r){var a=t-n;return 0===e?n:e===r?n+a:(e/=r/2)<1?a/2*Math.pow(2,10*(e-1))+n:a/2*(-Math.pow(2,-10*--e)+2)+n},easeInCirc:function(e,n,t,r){var a=t-n;return-a*(Math.sqrt(1-(e/=r)*e)-1)+n},easeOutCirc:function(e,n,t,r){var a=t-n;return a*Math.sqrt(1-(e=e/r-1)*e)+n},easeInOutCirc:function(e,n,t,r){var a=t-n;return(e/=r/2)<1?-a/2*(Math.sqrt(1-e*e)-1)+n:a/2*(Math.sqrt(1-(e-=2)*e)+1)+n},easeInElastic:function(e,n,t,r){var a,u,o,i=t-n;return o=1.70158,u=0,a=i,0===e?n:1===(e/=r)?n+i:(u||(u=.3*r),a<Math.abs(i)?(a=i,o=u/4):o=u/(2*Math.PI)*Math.asin(i/a),-(a*Math.pow(2,10*(e-=1))*Math.sin((e*r-o)*(2*Math.PI)/u))+n)},easeOutElastic:function(e,n,t,r){var a,u,o,i=t-n;return o=1.70158,u=0,a=i,0===e?n:1===(e/=r)?n+i:(u||(u=.3*r),a<Math.abs(i)?(a=i,o=u/4):o=u/(2*Math.PI)*Math.asin(i/a),a*Math.pow(2,-10*e)*Math.sin((e*r-o)*(2*Math.PI)/u)+i+n)},easeInOutElastic:function(e,n,t,r){var a,u,o,i=t-n;return o=1.70158,u=0,a=i,0===e?n:2===(e/=r/2)?n+i:(u||(u=r*(.3*1.5)),a<Math.abs(i)?(a=i,o=u/4):o=u/(2*Math.PI)*Math.asin(i/a),1>e?-.5*(a*Math.pow(2,10*(e-=1))*Math.sin((e*r-o)*(2*Math.PI)/u))+n:a*Math.pow(2,-10*(e-=1))*Math.sin((e*r-o)*(2*Math.PI)/u)*.5+i+n)},easeInBack:function(e,n,t,r,a){var u=t-n;return void 0===a&&(a=1.70158),u*(e/=r)*e*((a+1)*e-a)+n},easeOutBack:function(e,n,t,r,a){var u=t-n;return void 0===a&&(a=1.70158),u*((e=e/r-1)*e*((a+1)*e+a)+1)+n},easeInOutBack:function(e,n,t,r,a){var u=t-n;return void 0===a&&(a=1.70158),(e/=r/2)<1?u/2*(e*e*(((a*=1.525)+1)*e-a))+n:u/2*((e-=2)*e*(((a*=1.525)+1)*e+a)+2)+n},easeInBounce:function(e,n,r,a){var u,o=r-n;return u=t.easeOutBounce(a-e,0,o,a),o-u+n},easeOutBounce:function(e,n,t,r){var a=t-n;return(e/=r)<1/2.75?a*(7.5625*e*e)+n:2/2.75>e?a*(7.5625*(e-=1.5/2.75)*e+.75)+n:2.5/2.75>e?a*(7.5625*(e-=2.25/2.75)*e+.9375)+n:a*(7.5625*(e-=2.625/2.75)*e+.984375)+n},easeInOutBounce:function(e,n,r,a){var u,o=r-n;return a/2>e?(u=t.easeInBounce(2*e,0,o,a),.5*u+n):(u=t.easeOutBounce(2*e-a,0,o,a),.5*u+.5*o+n)}};e.exports=t}})}); |
{ | ||
"name": "react-tween-state", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "React animation.", | ||
@@ -11,3 +11,4 @@ "main": "lib/index.js", | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"build": "webpack -w -d" | ||
"build": "webpack -p", | ||
"start": "webpack -w -d" | ||
}, | ||
@@ -38,8 +39,12 @@ "repository": { | ||
"node-libs-browser": "^0.5.2", | ||
"react": "^0.13.3", | ||
"webpack": "^1.9.11" | ||
}, | ||
"peerDependencies": { | ||
"react-dom": "^0.14.2", | ||
"react": ">=0.14" | ||
}, | ||
"dependencies": { | ||
"raf": "^3.1.0", | ||
"tween-functions": "^1.0.1" | ||
} | ||
} |
@@ -80,3 +80,3 @@ # [React](http://facebook.github.io/react/) Tween State | ||
\* For a destructive animation, starting the next one with a delay still immediately kills the previous tween. If that's not your intention, try `setTimeout` or additive animation. `DESTRUCTIVE` + `duration` 0 effectively cancels all in-flight animations. | ||
\* For a destructive animation, starting the next one with a delay still immediately kills the previous tween. If that's not your intention, try `setTimeout` or additive animation. `DESTRUCTIVE` + `duration` 0 effectively cancels all in-flight animations, **skipping the easing function**. | ||
@@ -83,0 +83,0 @@ \*\* For an additive animation, since the tweens stack and never get destroyed, the end callback is effectively fired at the end of `duration`. |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
4
42061
4
7
24
1
+ Addedraf@^3.1.0
+ Addedacorn@5.7.4(transitive)
+ Addedamdefine@1.0.1(transitive)
+ Addedasap@2.0.6(transitive)
+ Addedast-types@0.9.6(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbase62@1.2.8(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedcommander@2.20.3(transitive)
+ Addedcommoner@0.10.8(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedcore-js@1.2.7(transitive)
+ Addeddefined@1.0.1(transitive)
+ Addeddetective@4.7.1(transitive)
+ Addedenvify@3.4.1(transitive)
+ Addedesprima@3.1.3(transitive)
+ Addedesprima-fb@15001.1.0-dev-harmony-fb(transitive)
+ Addedfbjs@0.6.1(transitive)
+ Addedglob@5.0.15(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addediconv-lite@0.4.24(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedjs-tokens@4.0.0(transitive)
+ Addedjstransform@11.0.3(transitive)
+ Addedloose-envify@1.4.0(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp@0.5.6(transitive)
+ Addedobject-assign@2.1.1(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedperformance-now@2.1.0(transitive)
+ Addedprivate@0.1.8(transitive)
+ Addedpromise@7.3.1(transitive)
+ Addedq@1.5.1(transitive)
+ Addedraf@3.4.1(transitive)
+ Addedreact@0.14.1018.3.1(transitive)
+ Addedreact-dom@0.14.10(transitive)
+ Addedrecast@0.11.23(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsource-map@0.4.40.5.7(transitive)
+ Addedthrough@2.3.8(transitive)
+ Addedua-parser-js@0.7.39(transitive)
+ Addedwhatwg-fetch@0.9.0(transitive)
+ Addedwrappy@1.0.2(transitive)