react-motion
Advanced tools
Comparing version 0.2.6 to 0.2.7
@@ -7,2 +7,9 @@ Legend: | ||
### Upcoming | ||
- [I] `Spring` `endValue` and `defaultValue` now support passing a simple number. You no longer have to do `endValue={{val: 10}}`. | ||
### 0.2.7 (August 6th 2015) | ||
- [F] Small bug where nested springs don't animate. #123 | ||
- [I] Support for all React 0.14.0 betas. | ||
### 0.2.6 (July 31th 2015) | ||
@@ -9,0 +16,0 @@ - [F] React-native warning's now gone, but also put into a separate file path. To require react-motion on react-native, do `require('react-motion/native')`. |
@@ -51,3 +51,3 @@ 'use strict'; | ||
var prevPrevState = _animRunning$i.prevState; | ||
var prevNextState = _animRunning$i.nextState; | ||
var prevNextState = animRunning[i].nextState; | ||
@@ -73,3 +73,5 @@ if (!active) { | ||
animRunning[i].nextState = step(timeStep / 1000, prevNextState); | ||
animRunning[i].prevState = prevNextState; | ||
var _ref = [prevNextState, animRunning[i].nextState]; | ||
animRunning[i].prevState = _ref[0]; | ||
prevNextState = _ref[1]; | ||
} | ||
@@ -82,3 +84,2 @@ } | ||
// Render and filter in one iteration. | ||
var newAnimRunning = []; | ||
var alpha = 1 + accumulatedTime / timeStep; | ||
@@ -90,7 +91,10 @@ for (var i = 0; i < animRunning.length; i++) { | ||
var render = _animRunning$i2.render; | ||
var active = _animRunning$i2.active; | ||
var nextState = _animRunning$i2.nextState; | ||
var prevState = _animRunning$i2.prevState; | ||
render(alpha, nextState, prevState); | ||
if (active) { | ||
} | ||
var newAnimRunning = []; | ||
for (var i = 0; i < animRunning.length; i++) { | ||
if (animRunning[i].active) { | ||
newAnimRunning.push(animRunning[i]); | ||
@@ -97,0 +101,0 @@ } |
'use strict'; | ||
exports.__esModule = true; | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
exports['default'] = components; | ||
@@ -73,10 +76,14 @@ | ||
}).forEach(function (key) { | ||
var _extends2, _extends3; | ||
hasNewKey = true; | ||
var enterValue = willEnter(key, mergedValue[key], endValue, currValue, currVelocity); | ||
currValue[key] = enterValue; | ||
// We can mutate this here because mergeDiff returns a new Obj | ||
mergedValue[key] = enterValue; | ||
currVelocity[key] = _mapTree2['default'](_zero2['default'], currValue[key]); | ||
currValue = _extends({}, currValue, (_extends2 = {}, _extends2[key] = enterValue, _extends2)); | ||
currVelocity = _extends({}, currVelocity, (_extends3 = {}, _extends3[key] = _mapTree2['default'](_zero2['default'], enterValue), _extends3)); | ||
}); | ||
} | ||
var newCurrValue = _updateTree.updateCurrValue(timestep, currValue, currVelocity, mergedValue); | ||
@@ -103,4 +110,4 @@ var newCurrVelocity = _updateTree.updateCurrVelocity(timestep, currValue, currVelocity, mergedValue); | ||
propTypes: { | ||
defaultValue: PropTypes.oneOfType([PropTypes.object, PropTypes.array]), | ||
endValue: PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.array]).isRequired, | ||
defaultValue: PropTypes.oneOfType([PropTypes.object, PropTypes.array, PropTypes.number]), | ||
endValue: PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.array, PropTypes.number]).isRequired, | ||
children: PropTypes.func.isRequired | ||
@@ -183,2 +190,4 @@ }, | ||
// TODO: warn when obj uses numerical keys | ||
// TODO: warn when endValue doesn't contain a val | ||
var TransitionSpring = React.createClass({ | ||
@@ -185,0 +194,0 @@ displayName: 'TransitionSpring', |
@@ -7,8 +7,12 @@ "use strict"; | ||
function reorderKeys(obj, f) { | ||
return f(Object.keys(obj)).reduce(function (ret, key) { | ||
var newKeys = f(Object.keys(obj)); | ||
var ret = {}; | ||
for (var i = 0; i < newKeys.length; i++) { | ||
var key = newKeys[i]; | ||
ret[key] = obj[key]; | ||
return ret; | ||
}, {}); | ||
} | ||
return ret; | ||
} | ||
module.exports = exports["default"]; |
@@ -69,5 +69,4 @@ 'use strict'; | ||
// TODO: refactor common logic with updateCurrVelocity | ||
function updateCurrValue(frameRate, currValue, currVelocity, endValue, k, b) { | ||
// TODO: refactor common logic with _updateCurrVelocity | ||
function _updateCurrValue(frameRate, currValue, currVelocity, endValue, k, b) { | ||
if (endValue == null) { | ||
@@ -93,3 +92,3 @@ return null; | ||
var ret = { | ||
val: updateCurrValue(frameRate, currValue.val, currVelocity.val, endValue.val, _k, _b) | ||
val: _updateCurrValue(frameRate, currValue.val, currVelocity.val, endValue.val, _k, _b) | ||
}; | ||
@@ -103,3 +102,3 @@ if (endValue.config) { | ||
return endValue.map(function (_, i) { | ||
return updateCurrValue(frameRate, currValue[i], currVelocity[i], endValue[i], k, b); | ||
return _updateCurrValue(frameRate, currValue[i], currVelocity[i], endValue[i], k, b); | ||
}); | ||
@@ -109,3 +108,3 @@ } | ||
return Object.keys(endValue).reduce(function (ret, key) { | ||
ret[key] = updateCurrValue(frameRate, currValue[key], currVelocity[key], endValue[key], k, b); | ||
ret[key] = _updateCurrValue(frameRate, currValue[key], currVelocity[key], endValue[key], k, b); | ||
return ret; | ||
@@ -117,3 +116,15 @@ }, {}); | ||
function updateCurrVelocity(frameRate, currValue, currVelocity, endValue, k, b) { | ||
function updateCurrValue(frameRate, currValue, currVelocity, endValue) { | ||
if (typeof endValue === 'number') { | ||
var _presets$noWobble = _presets2['default'].noWobble; | ||
var k = _presets$noWobble[0]; | ||
var b = _presets$noWobble[1]; | ||
return _stepper2['default'](frameRate, currValue, currVelocity, endValue, k, b)[0]; | ||
} | ||
return _updateCurrValue(frameRate, currValue, currVelocity, endValue); | ||
} | ||
function _updateCurrVelocity(frameRate, currValue, currVelocity, endValue, k, b) { | ||
if (endValue == null) { | ||
@@ -139,3 +150,3 @@ return null; | ||
var ret = { | ||
val: updateCurrVelocity(frameRate, currValue.val, currVelocity.val, endValue.val, _k, _b) | ||
val: _updateCurrVelocity(frameRate, currValue.val, currVelocity.val, endValue.val, _k, _b) | ||
}; | ||
@@ -149,3 +160,3 @@ if (endValue.config) { | ||
return endValue.map(function (_, i) { | ||
return updateCurrVelocity(frameRate, currValue[i], currVelocity[i], endValue[i], k, b); | ||
return _updateCurrVelocity(frameRate, currValue[i], currVelocity[i], endValue[i], k, b); | ||
}); | ||
@@ -155,3 +166,3 @@ } | ||
return Object.keys(endValue).reduce(function (ret, key) { | ||
ret[key] = updateCurrVelocity(frameRate, currValue[key], currVelocity[key], endValue[key], k, b); | ||
ret[key] = _updateCurrVelocity(frameRate, currValue[key], currVelocity[key], endValue[key], k, b); | ||
return ret; | ||
@@ -161,2 +172,14 @@ }, {}); | ||
return _mapTree2['default'](_zero2['default'], currVelocity); | ||
} | ||
function updateCurrVelocity(frameRate, currValue, currVelocity, endValue) { | ||
if (typeof endValue === 'number') { | ||
var _presets$noWobble2 = _presets2['default'].noWobble; | ||
var k = _presets$noWobble2[0]; | ||
var b = _presets$noWobble2[1]; | ||
return _stepper2['default'](frameRate, currValue, currVelocity, endValue, k, b)[1]; | ||
} | ||
return _updateCurrVelocity(frameRate, currValue, currVelocity, endValue); | ||
} |
{ | ||
"name": "react-motion", | ||
"version": "0.2.6", | ||
"version": "0.2.7", | ||
"description": "A spring that solves your animation problems.", | ||
"main": "lib/react-motion.js", | ||
"peerDependencies": { | ||
"react": ">=0.13.2 || 0.14.0-beta1" | ||
"react": ">=0.13.2 || ^0.14.0-beta1" | ||
}, | ||
@@ -20,3 +20,3 @@ "devDependencies": { | ||
"eslint-plugin-react": "^2.7.0", | ||
"inject-loader": "plasticine/inject-loader#master", | ||
"inject-loader": "^2.0.1", | ||
"isparta-loader": "^0.2.0", | ||
@@ -28,3 +28,3 @@ "karma": "^0.12.37", | ||
"karma-phantomjs-launcher": "^0.2.0", | ||
"karma-webpack": "^1.6.0", | ||
"karma-webpack": "1.6.0", | ||
"lodash.range": "^3.0.1", | ||
@@ -31,0 +31,0 @@ "phantomjs": "^1.9.17", |
@@ -8,3 +8,3 @@ # React-Motion | ||
```js | ||
<Spring endValue={{val: 10}}> | ||
<Spring defaultValue={{val: 0}} endValue={{val: 10}}> | ||
{interpolated => <div>{interpolated.val}</div>} | ||
@@ -14,3 +14,3 @@ </Spring> | ||
Animate a counter to `10`, from whatever value it currently is. For more advanced usage, see [below](#presets). | ||
Animate a counter from `0` `10`. For more advanced usage, see [below](#presets). | ||
@@ -242,5 +242,3 @@ Npm: | ||
willLeave(key, value, endValue, currentValue, currentSpeed) { | ||
if (currentValue[key].opacity.val === 0 && currentSpeed[key].opacity.val === 0) { | ||
return null; // kill component when opacity reaches 0 | ||
} | ||
// the key with this value is truly killed when the values reaches destination | ||
return { | ||
@@ -297,2 +295,4 @@ height: {val: 0}, | ||
**Note**: object keys creation order is now guaranteed by the specs, except for integer keys, which follow ascending order and should not be used with `TransitionSpring` (unless that behavior's what you want). Fortunately, you can just add a letter to your key to solve the integer order problem. | ||
#### `utils.reorderKeys(object, newKeysFunction)` | ||
@@ -299,0 +299,0 @@ `newKeysFunction` will receive, as arguments, the array of keys in `object` and should return a new array of keys (with e.g. order changed and/or keys missing). `reorderKeys` will then return a new object similar to `object`, but with the keys in the order `newKeysFunction` dictated. |
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
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
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
High entropy strings
Supply chain riskContains high entropy strings. This could be a sign of encrypted data, leaked secrets or obfuscated code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
0
2
0
1
93530
24
848