Skip to content

Commit

Permalink
fix merge errors
Browse files Browse the repository at this point in the history
  • Loading branch information
drcmda committed Jun 21, 2018
2 parents 3dc4685 + 7aca329 commit e3a353f
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 15 deletions.
11 changes: 3 additions & 8 deletions .size-snapshot.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
{
"dist/dom.umd.js": {
"bundled": 86825,
"minified": 35401,
"gzipped": 11857
},
"dist/addons.umd.js": {
"bundled": 15720,
"minified": 5853,
"gzipped": 2141
},
"dist/web.umd.js": {
"bundled": 86602,
"minified": 35758,
"gzipped": 12088
"bundled": 86673,
"minified": 35786,
"gzipped": 12097
}
}
2 changes: 2 additions & 0 deletions API-OVERVIEW.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ You can interpolate almost everything, from numbers, colors, svg-paths, percenta
}}>
```

The `from` prop denotes initial values and `to` end-state values the spring will animate towards. Once the spring starts animating `from` plays no role any longer, it will from now on remember its current values and animate from there if you update `to`.

A couple of extra props you might be interested in are `onRest`, which fires once the animations stops, `onFrame`, which fires on every frame and gives you the animation value, `reset`, which literally resets the spring so that it goes through `from` to `to` again, `immediate` which can enforce values to spring to their to-values immediately (can be `true` for a zero-time spring or a function which receives the key names and returns `true` or `false` individually).

##### Animating 'auto'
Expand Down
20 changes: 13 additions & 7 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ import { config } from 'react-spring'
*/
```

- tension, controls the initial plus force of the spring when let loose (default: 170)
- friction, controls the opposition or antagonistic minus force (default: 26)
- restSpeedThreshold, precision (default: 0.0001)
- restDisplacementThreshold, displacement precision (default: 0.0001)
* tension, controls the initial plus force of the spring when let loose (default: 170)
* friction, controls the opposition or antagonistic minus force (default: 26)
* velocity, controls the initial velocity of the object attached to the spring (default: 0)
* overshootClamping, controls if the spring should be clamped and not bounce (default: false)
* restSpeedThreshold, precision (default: 0.0001)
* restDisplacementThreshold, displacement precision (default: 0.0001)

# Spring

Expand All @@ -36,6 +38,8 @@ class Spring extends React.PureComponent {
from: PropTypes.object,
// Animates to ...
to: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
// Callback when the animation starts to animate
onStart: PropTypes.func,
// Callback when the animation comes to a still-stand
onRest: PropTypes.func,
// Frame by frame callback, first argument passed is the animated value
Expand All @@ -51,8 +55,10 @@ class Spring extends React.PureComponent {
immediate: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),
// Won't start animations, so they can be controlled from outside
hold: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),
// Spring config ({ tension, friction } or a function receiving a name)
// Spring config ({ tension, friction, ... } or a function receiving a name)
config: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
// Animation start delay, optional
delay: PropTypes.number,
// When true it literally resets: from -> to
reset: PropTypes.bool,
}
Expand Down Expand Up @@ -82,7 +88,7 @@ class Transition extends React.PureComponent {
from: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
// Animated styles when the component is mounted
enter: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
// Unmpount styles
// Unmount styles
leave: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
//
update: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
Expand Down Expand Up @@ -215,7 +221,7 @@ export default class Keyframes extends React.Component {
static create = p => s => props => (
<Keyframes primitive={p} states={s} {...props} />
)

// Factory functions, take an object with named slots.
// A slot can be raw-props, an array of props, or an async function
static Spring = Keyframes.create(Spring)
Expand Down
4 changes: 4 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ declare module 'react-spring' {
* @default {}
*/
to: DS;
/**
* Callback when the animation starts to animate
*/
onStart?: () => void;
/**
* Callback when the animation comes to a still-stand
*/
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"@babel/preset-env": "7.0.0-beta.49",
"@babel/preset-react": "7.0.0-beta.49",
"@babel/preset-stage-3": "^7.0.0-beta.49",
"@types/react": "^16.4.0",
"babel-core": "7.0.0-bridge.0",
"babel-jest": "^23.0.1",
"babel-plugin-transform-react-remove-prop-types": "0.4.13",
Expand Down
5 changes: 5 additions & 0 deletions src/Spring.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default class Spring extends React.Component {
to: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
from: PropTypes.object,
native: PropTypes.bool,
onStart: PropTypes.func,
onRest: PropTypes.func,
onFrame: PropTypes.func,
children: PropTypes.oneOfType([
Expand Down Expand Up @@ -197,6 +198,8 @@ export default class Spring extends React.Component {
}

start() {
const { onStart } = this.props

let fn = () =>
this.getAnimations().forEach(animation => animation.start(resolve))
let resolve,
Expand All @@ -206,6 +209,8 @@ export default class Spring extends React.Component {
return (this.timeout = setTimeout(() => fn(), this.props.delay))
}

if (onStart) onStart()

fn()
return promise
}
Expand Down
10 changes: 10 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,12 @@
version "10.1.2"
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.1.2.tgz#1b928a0baa408fc8ae3ac012cc81375addc147c6"

"@types/react@^16.4.0":
version "16.4.0"
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.4.0.tgz#f7f639837bf1f8635f57616b12a1b0d193b6343a"
dependencies:
csstype "^2.2.0"

"@webassemblyjs/[email protected]":
version "1.4.3"
resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.4.3.tgz#3b3f6fced944d8660273347533e6d4d315b5934a"
Expand Down Expand Up @@ -1711,6 +1717,10 @@ [email protected], "cssom@>= 0.3.2 < 0.4.0":
dependencies:
cssom "0.3.x"

csstype@^2.2.0:
version "2.5.4"
resolved "https://registry.yarnpkg.com/csstype/-/csstype-2.5.4.tgz#93850187209b6d0a71d30a85abc95a6ae3f3e8cd"

cyclist@~0.2.2:
version "0.2.2"
resolved "https://registry.yarnpkg.com/cyclist/-/cyclist-0.2.2.tgz#1b33792e11e914a2fd6d6ed6447464444e5fa640"
Expand Down

0 comments on commit e3a353f

Please sign in to comment.