Skip to content

Commit f7b429d

Browse files
committed
fix/remove keyframes
1 parent 2ab4d27 commit f7b429d

File tree

4 files changed

+36
-41
lines changed

4 files changed

+36
-41
lines changed

examples/components/examples-hooks.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,15 +171,15 @@ return transitions.map(({ item, props, key }) => (
171171
},
172172
{
173173
name: 'keyframes-script',
174-
title: 'Keyframes scripting',
174+
title: 'Spring scripting',
175175
link: 'https://codesandbox.io/embed/141nrz6v73',
176-
tags: ['useKeyframes'],
176+
tags: ['useSpring'],
177177
},
178178
{
179179
name: 'keyframes-blackflag',
180-
title: 'Keyframes reset script',
180+
title: 'Spring reset script',
181181
link: 'https://codesandbox.io/embed/8ypj5vq6m9',
182-
tags: ['useKeyframes'],
182+
tags: ['useSpring'],
183183
code: {
184184
useKeyframes: `const interp = i => r =>
185185
\`translate3d(0, \${15 * Math.sin(r + (i * 2 * Math.PI) / 1.6)}px, 0)\`

examples/demos/keyframes-blackflag/index.js

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,21 @@
11
import React from 'react'
2-
import { useKeyframes, animated } from 'react-spring/hooks'
2+
import { useSpring, animated } from 'react-spring/hooks'
33
import range from 'lodash-es/range'
44
import './styles.css'
55

66
const items = range(4)
77
const interp = i => r =>
88
`translate3d(0, ${15 * Math.sin(r + (i * 2 * Math.PI) / 1.6)}px, 0)`
9-
const useScript = useKeyframes.spring(
10-
async next => {
11-
while (1)
12-
await next({
13-
radians: 2 * Math.PI,
14-
from: { radians: 0 },
15-
reset: true, // <----------- this doesn't work
16-
config: { duration: 3500 },
17-
})
18-
},
19-
{ radians: 0 }
20-
)
219

2210
export default function App() {
23-
const props = useScript()
11+
const props = useSpring({
12+
to: async next => {
13+
while (1) await next({ radians: 2 * Math.PI })
14+
},
15+
from: { radians: 0 },
16+
reset: true,
17+
config: { duration: 3500 },
18+
})
2419
return (
2520
<div className="script-bf-main">
2621
{items.map(i => (

examples/demos/keyframes-script/index.js

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
import React, { useEffect } from 'react'
2-
import { useKeyframes, animated } from 'react-spring/hooks'
2+
import { useSpring, animated } from 'react-spring/hooks'
33
import './styles.css'
44

5-
const useScript = useKeyframes.spring(async next => {
6-
while (true) {
7-
await next({
8-
left: '0%',
9-
top: '0%',
10-
width: '100%',
11-
height: '100%',
12-
config: { duration: 0 },
13-
})
14-
await next({ height: '50%' })
15-
await next({ width: '50%', left: '50%' })
16-
await next({ top: '0%', height: '100%' })
17-
await next({ top: '50%', height: '50%' })
18-
await next({ width: '100%', left: '0%' })
19-
await next({ width: '50%' })
20-
await next({ top: '0%', height: '100%' })
21-
await next({ width: '100%' })
22-
}
23-
})
24-
255
export default function App() {
26-
const props = useScript()
6+
const props = useSpring({
7+
from: { left: '0%', top: '0%', width: '0%', height: '0%' },
8+
to: async next => {
9+
while (1) {
10+
await next({
11+
left: '0%',
12+
top: '0%',
13+
width: '100%',
14+
height: '100%',
15+
})
16+
await next({ height: '50%' })
17+
await next({ width: '50%', left: '50%' })
18+
await next({ top: '0%', height: '100%' })
19+
await next({ top: '50%', height: '50%' })
20+
await next({ width: '100%', left: '0%' })
21+
await next({ width: '50%' })
22+
await next({ top: '0%', height: '100%' })
23+
await next({ width: '100%' })
24+
}
25+
},
26+
})
2727
return (
2828
<div className="script-main">
2929
<animated.div className="script-box" style={props} />

examples/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import examples from './components/examples-hooks'
66
import './styles.css'
77

88
const DEBUG = false
9-
//const DEBUG = 'simple'
9+
//const DEBUG = 'scrip'
1010

1111
ReactDOM.render(
1212
<DemoGrid fullscreen={!!DEBUG}>

0 commit comments

Comments
 (0)