react-motion
Advanced tools
Comparing version 0.3.0 to 0.3.1
@@ -7,2 +7,7 @@ Legend: | ||
### 0.3.1 (October 14th 2015) | ||
- [F] Handle `null` and `undefined` in `style`/`styles`. #181 | ||
- [I] Library's now partially annotated with [Flow](http://flowtype.org). | ||
- [I] Related to above, the `src/` folder is now exposed on npm so that you can take advantage of Flow by using: `import {Motion} from 'react-motion/src/react-motion'` directly, instead of the old, prebuilt `import {Motion} from 'react-motion'`. **This is experimental** and intentionally undocumented. You'll have to adjust your webpack/browserify configurations to require these original source files correctly. No harm trying of course. It's just some type annotations =). | ||
### 0.3.0 (September 30th 2015) | ||
@@ -9,0 +14,0 @@ - [B] API revamp! See https://github.com/chenglou/react-motion/wiki for more details. Thanks! |
@@ -1,5 +0,5 @@ | ||
"use strict"; | ||
'use strict'; | ||
exports.__esModule = true; | ||
exports["default"] = hasReachedStyle; | ||
exports['default'] = hasReachedStyle; | ||
@@ -13,3 +13,3 @@ function hasReachedStyle(currentStyle, style) { | ||
var destValue = style[key]; | ||
if (!destValue.config) { | ||
if (destValue == null || !destValue.config) { | ||
// not a spring config | ||
@@ -29,2 +29,2 @@ continue; | ||
module.exports = exports["default"]; | ||
module.exports = exports['default']; |
@@ -0,7 +1,9 @@ | ||
// this function is allocation-less thanks to babel, which transforms the tail | ||
// calls into loops | ||
"use strict"; | ||
'use strict'; | ||
exports.__esModule = true; | ||
exports["default"] = mergeDiff; | ||
exports['default'] = mergeDiff; | ||
function mergeDiffArr(_x, _x2, _x3, _x4, _x5, _x6, _x7) { | ||
@@ -109,2 +111,2 @@ var _again = true; | ||
module.exports = exports["default"]; | ||
module.exports = exports['default']; |
@@ -0,7 +1,9 @@ | ||
// currentStyle keeps the info about whether a prop is configured as a spring | ||
// or if it's just a random prop that happens to be present on the style | ||
"use strict"; | ||
'use strict'; | ||
exports.__esModule = true; | ||
exports["default"] = noVelocity; | ||
exports['default'] = noVelocity; | ||
@@ -13,3 +15,3 @@ function noVelocity(currentVelocity, currentStyle) { | ||
} | ||
if (currentStyle[key].config && currentVelocity[key] !== 0) { | ||
if (currentStyle[key] != null && currentStyle[key].config && currentVelocity[key] !== 0) { | ||
return false; | ||
@@ -21,2 +23,2 @@ } | ||
module.exports = exports["default"]; | ||
module.exports = exports['default']; |
@@ -0,1 +1,2 @@ | ||
// [stiffness, damping] | ||
@@ -2,0 +3,0 @@ "use strict"; |
@@ -12,4 +12,2 @@ 'use strict'; | ||
// instead of exposing {val: bla, config: bla}, use a helper | ||
function spring(val) { | ||
@@ -16,0 +14,0 @@ var config = arguments.length <= 1 || arguments[1] === undefined ? _presets2['default'].noWobble : arguments[1]; |
@@ -5,2 +5,3 @@ "use strict"; | ||
exports["default"] = stepper; | ||
var errorMargin = 0.0001; | ||
@@ -7,0 +8,0 @@ |
@@ -1,6 +0,9 @@ | ||
// turn {x: {val: 1, config: [1, 2]}, y: 2} into {x: 1, y: 2} | ||
"use strict"; | ||
// turn {x: {val: 1, config: [1, 2]}, y: 2} generated by | ||
// `{x: spring(1, [1, 2]), y: 2}` into {x: 1, y: 2} | ||
'use strict'; | ||
exports.__esModule = true; | ||
exports["default"] = stripStyle; | ||
exports['default'] = stripStyle; | ||
@@ -13,3 +16,3 @@ function stripStyle(style) { | ||
} | ||
ret[key] = style[key].val == null ? style[key] : style[key].val; | ||
ret[key] = style[key] == null || style[key].val == null ? style[key] : style[key].val; | ||
} | ||
@@ -19,2 +22,2 @@ return ret; | ||
module.exports = exports["default"]; | ||
module.exports = exports['default']; |
@@ -0,1 +1,4 @@ | ||
// TODO: refactor common logic with updateCurrValue and updateCurrVelocity | ||
'use strict'; | ||
@@ -14,4 +17,6 @@ | ||
// TODO: refactor common logic with updateCurrValue and updateCurrVelocity | ||
var _spring = require('./spring'); | ||
var _spring2 = _interopRequireDefault(_spring); | ||
function interpolateValue(alpha, nextStyle, prevStyle) { | ||
@@ -29,3 +34,3 @@ // might be used by a TransitionMotion, where prevStyle might not exist anymore | ||
if (!nextStyle[key].config) { | ||
if (nextStyle[key] == null || !nextStyle[key].config) { | ||
ret[key] = nextStyle[key]; | ||
@@ -36,6 +41,3 @@ // not a spring config, not something we want to interpolate | ||
var prevValue = prevStyle[key].config ? prevStyle[key].val : prevStyle[key]; | ||
ret[key] = { | ||
val: nextStyle[key].val * alpha + prevValue * (1 - alpha), | ||
config: nextStyle[key].config | ||
}; | ||
ret[key] = _spring2['default'](nextStyle[key].val * alpha + prevValue * (1 - alpha), nextStyle[key].config); | ||
} | ||
@@ -54,3 +56,3 @@ | ||
} | ||
if (!style[key].config) { | ||
if (style[key] == null || !style[key].config) { | ||
ret[key] = style[key]; | ||
@@ -67,6 +69,3 @@ // not a spring config, not something we want to interpolate | ||
currentStyle[key].val == null ? currentStyle[key] : currentStyle[key].val, currentVelocity[key], style[key].val, k, b)[0]; | ||
ret[key] = { | ||
val: val, | ||
config: style[key].config | ||
}; | ||
ret[key] = _spring2['default'](val, style[key].config); | ||
} | ||
@@ -82,3 +81,3 @@ return ret; | ||
} | ||
if (!style[key].config) { | ||
if (style[key] == null || !style[key].config) { | ||
// not a spring config, not something we want to interpolate | ||
@@ -85,0 +84,0 @@ ret[key] = 0; |
@@ -0,1 +1,2 @@ | ||
// used by the tree-walking updates and springs. Avoids some allocations | ||
@@ -2,0 +3,0 @@ "use strict"; |
{ | ||
"name": "react-motion", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "A spring that solves your animation problems.", | ||
"main": "lib/react-motion.js", | ||
"peerDependencies": { | ||
"react": ">=0.13.2 || ^0.14.0-rc1" | ||
"react": ">=0.13.2 || ^0.14" | ||
}, | ||
@@ -16,2 +16,5 @@ "devDependencies": { | ||
"codemirror": "^5.5.0", | ||
"colors-mini": "^1.0.2", | ||
"css-loader": "^0.19.0", | ||
"diff": "^2.1.3", | ||
"eslint": "^0.24.1", | ||
@@ -24,12 +27,14 @@ "eslint-config-airbnb": "0.0.6", | ||
"jasmine-core": "^2.3.4", | ||
"karma": "^0.12.37", | ||
"karma-coverage": "^0.4.2", | ||
"karma": "^0.13.10", | ||
"karma-coverage": "^0.5.2", | ||
"karma-jasmine": "^0.3.6", | ||
"karma-nyan-reporter": "^0.2.1", | ||
"karma-phantomjs-launcher": "^0.2.0", | ||
"karma-webpack": "1.6.0", | ||
"karma-webpack": "^1.7.0", | ||
"lodash.isequal": "^3.0.4", | ||
"lodash.range": "^3.0.1", | ||
"phantomjs": "^1.9.17", | ||
"react": "^0.14.0", | ||
"react-codemirror": "^0.1.2", | ||
"react-hot-loader": "^1.2.8", | ||
"style-loader": "^0.12.4", | ||
"webpack": "^1.10.1", | ||
@@ -39,10 +44,11 @@ "webpack-dev-server": "^1.10.1" | ||
"scripts": { | ||
"start": "NODE_ENV=development node server.js", | ||
"build-demos": "NODE_ENV=production webpack", | ||
"start": "node server.js", | ||
"build-demos": "webpack", | ||
"lint": "eslint --ext .js,.jsx .", | ||
"prerelease": "babel src --out-dir lib && babel native/non-compiled.js > native/index.js && NODE_ENV=production webpack --config webpack.prod.config.js", | ||
"karma": "NODE_ENV=development karma start ./karma.conf.js", | ||
"test": "npm run karma -- --single-run --reporters nyan", | ||
"test:dev": "npm run karma -- --no-single-run --auto-watch --reporters nyan", | ||
"test:cov": "COVERAGE=1 npm run karma -- --single-run --reporters coverage" | ||
"prerelease": "babel src --out-dir lib && babel native/non-compiled.js > native/index.js && webpack --config webpack.prod.config.js", | ||
"test": "karma start ./karma.conf.js --single-run", | ||
"test:travis": "karma start ./karma.conf.js --single-run", | ||
"test:dev": "karma start ./karma.conf.js --no-single-run --auto-watch", | ||
"test:cov": "karma start ./karma.conf.js --single-run --reporters coverage", | ||
"gh-pages": "git fetch origin && git checkout gh-pages && git reset --hard origin/gh-pages && git rebase origin/master --force-rebase && npm run build-demos && git add . && git commit --amend --no-edit && git push origin gh-pages --force && git checkout master" | ||
}, | ||
@@ -49,0 +55,0 @@ "repository": { |
# React-Motion | ||
[![Build Status](https://travis-ci.org/chenglou/react-motion.svg?branch=master)](https://travis-ci.org/chenglou/react-motion) | ||
[![npm version](https://badge.fury.io/js/react-motion.svg)](https://www.npmjs.com/package/react-motion) | ||
@@ -15,3 +16,3 @@ [![Bower version](https://badge.fury.io/bo/react-motion.svg)](http://badge.fury.io/bo/react-motion) | ||
Animate a counter from `0` `10`. For more advanced usage, see below. | ||
Animate a counter from `0` to `10`. For more advanced usage, see below. | ||
@@ -37,10 +38,10 @@ ## Install | ||
## Demos | ||
- [Simple Transition](https://cdn.rawgit.com/chenglou/react-motion/043231a84e420ba1cc7f5b0ceb1753a6406d38f1/demos/demo0/index.html) | ||
- [Chat Heads](https://cdn.rawgit.com/chenglou/react-motion/043231a84e420ba1cc7f5b0ceb1753a6406d38f1/demos/demo1/index.html) | ||
- [Draggable Balls](https://cdn.rawgit.com/chenglou/react-motion/043231a84e420ba1cc7f5b0ceb1753a6406d38f1/demos/demo2/index.html) | ||
- [TodoMVC List Transition](https://cdn.rawgit.com/chenglou/react-motion/043231a84e420ba1cc7f5b0ceb1753a6406d38f1/demos/demo3/index.html) | ||
- [Photo Gallery](https://cdn.rawgit.com/chenglou/react-motion/043231a84e420ba1cc7f5b0ceb1753a6406d38f1/demos/demo4/index.html) | ||
- [Spring Parameters Chooser](https://cdn.rawgit.com/chenglou/react-motion/043231a84e420ba1cc7f5b0ceb1753a6406d38f1/demos/demo5/index.html) | ||
- [Water Ripples](https://cdn.rawgit.com/chenglou/react-motion/043231a84e420ba1cc7f5b0ceb1753a6406d38f1/demos/demo7/index.html) | ||
- [Draggable List](https://cdn.rawgit.com/chenglou/react-motion/043231a84e420ba1cc7f5b0ceb1753a6406d38f1/demos/demo8/index.html) | ||
- [Simple Transition](http://chenglou.github.io/react-motion/demos/demo0-simple-transition) | ||
- [Chat Heads](http://chenglou.github.io/react-motion/demos/demo1-chat-heads) | ||
- [Draggable Balls](http://chenglou.github.io/react-motion/demos/demo2-draggable-balls) | ||
- [TodoMVC List Transition](http://chenglou.github.io/react-motion/demos/demo3-todomvc-list-transition) | ||
- [Photo Gallery](http://chenglou.github.io/react-motion/demos/demo4-photo-gallery) | ||
- [Spring Parameters Chooser](http://chenglou.github.io/react-motion/demos/demo5-spring-parameters-chooser) | ||
- [Water Ripples](http://chenglou.github.io/react-motion/demos/demo7-water-ripples) | ||
- [Draggable List](http://chenglou.github.io/react-motion/demos/demo8-draggable-list) | ||
@@ -182,3 +183,3 @@ ## What does this library try to solve? | ||
return { | ||
opacity: spring(0), // make opacity teach 0, after which we can kill the key | ||
opacity: spring(0), // make opacity reach 0, after which we can kill the key | ||
text: style.text, | ||
@@ -219,3 +220,3 @@ }; | ||
### `presets` | ||
Some tasteful, commonly used spring presets you can plug into your `style` like so: `{val: 10, config: presets.wobbly}`. [See here](https://github.com/chenglou/react-motion/blob/043231a84e420ba1cc7f5b0ceb1753a6406d38f1/src/presets.js). | ||
Some tasteful, commonly used spring presets you can plug into your `style` like so: `spring(10, presets.wobbly)`. [See here](https://github.com/chenglou/react-motion/blob/043231a84e420ba1cc7f5b0ceb1753a6406d38f1/src/presets.js). | ||
@@ -240,3 +241,3 @@ ### `utils` | ||
[Hard-coded duration goes against fluid interfaces](https://twitter.com/andy_matuschak/status/566736015188963328). If your animation is interrupted mid-way, you'd get a weird completion animation if you hard-coded the time. That being said, in the demo section there's a great [Spring Parameters Chooser](https://cdn.rawgit.com/chenglou/react-motion/043231a84e420ba1cc7f5b0ceb1753a6406d38f1/demos/demo5/index.html) for you to have a feel of what spring is appropriate, rather than guessing a duration in the dark. | ||
[Hard-coded duration goes against fluid interfaces](https://twitter.com/andy_matuschak/status/566736015188963328). If your animation is interrupted mid-way, you'd get a weird completion animation if you hard-coded the time. That being said, in the demo section there's a great [Spring Parameters Chooser](http://chenglou.github.io/react-motion/demos/demo5-spring-parameters-chooser/) for you to have a feel of what spring is appropriate, rather than guessing a duration in the dark. | ||
@@ -243,0 +244,0 @@ - How do I unmount the `TransitionMotion` container itself? |
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
36
1684
256
80561
30