Skip to content

Commit

Permalink
Block Editor: update react-spring to 9.2.4 (#30979)
Browse files Browse the repository at this point in the history
  • Loading branch information
gwwar authored Sep 13, 2021
1 parent c596a61 commit 2c61bf3
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 26 deletions.
6 changes: 0 additions & 6 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,6 @@ module.exports = {
message:
'Path access on WordPress dependencies is not allowed.',
},
{
selector:
'ImportDeclaration[source.value=/^react-spring(?!\\u002Fweb.cjs)/]',
message:
'The react-spring dependency must specify CommonJS bundle: react-spring/web.cjs',
},
{
selector:
'CallExpression[callee.name="deprecated"] Property[key.name="version"][value.value=/' +
Expand Down
60 changes: 50 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/block-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
],
"dependencies": {
"@babel/runtime": "^7.13.10",
"@react-spring/web": "^9.2.4",
"@wordpress/a11y": "file:../a11y",
"@wordpress/blob": "file:../blob",
"@wordpress/block-serialization-default-parser": "file:../block-serialization-default-parser",
Expand Down Expand Up @@ -65,7 +66,6 @@
"lodash": "^4.17.21",
"memize": "^1.1.0",
"react-autosize-textarea": "^7.1.0",
"react-spring": "^8.0.19",
"redux-multi": "^0.1.12",
"rememo": "^3.0.0",
"tinycolor2": "^1.4.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/block-editor/src/components/list-view/leaf.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { animated } from 'react-spring/web.cjs';
import { animated } from '@react-spring/web';
import classnames from 'classnames';

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { useSpring } from 'react-spring/web.cjs';
import { useSpring } from '@react-spring/web';

/**
* WordPress dependencies
Expand Down Expand Up @@ -136,19 +136,20 @@ function useMovingAnimation( {
}

// Called for every frame computed by useSpring.
function onFrame( { x, y } ) {
function onChange( { value } ) {
let { x, y } = value;
x = Math.round( x );
y = Math.round( y );

if ( x !== onFrame.x || y !== onFrame.y ) {
if ( x !== onChange.x || y !== onChange.y ) {
onFrameChange( { x, y } );
onFrame.x = x;
onFrame.y = y;
onChange.x = x;
onChange.y = y;
}
}

onFrame.x = 0;
onFrame.y = 0;
onChange.x = 0;
onChange.y = 0;

useSpring( {
from: {
Expand All @@ -162,7 +163,7 @@ function useMovingAnimation( {
reset: triggeredAnimation !== finishedAnimation,
config: { mass: 5, tension: 2000, friction: 200 },
immediate: prefersReducedMotion,
onFrame,
onChange,
} );

return ref;
Expand Down

0 comments on commit 2c61bf3

Please sign in to comment.