Skip to content

Commit

Permalink
Remove useSelect from useMovingAnimation
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgefilipecosta committed Jul 18, 2019
1 parent 8627ff0 commit 357b53d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 3 additions & 1 deletion packages/block-editor/src/components/block-list/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
import { KeyboardShortcuts, withFilters } from '@wordpress/components';
import { __, sprintf } from '@wordpress/i18n';
import {
useSelect,
withDispatch,
withSelect,
} from '@wordpress/data';
Expand Down Expand Up @@ -251,8 +252,9 @@ function BlockListBlock( {
}
}, [ isFirstMultiSelected ] );

const isTyping = useSelect( ( select ) => select( 'core/block-editor' ).isTyping() );
// Block Reordering animation
const style = useMovingAnimation( wrapper, isSelected || isPartOfMultiSelection, enableAnimation, animateOnChange );
const style = useMovingAnimation( wrapper, isSelected || isPartOfMultiSelection, enableAnimation && ! isTyping, animateOnChange );

// Other event handlers

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { useSpring, interpolate } from 'react-spring/web.cjs';
*/
import { useState, useLayoutEffect } from '@wordpress/element';
import { useReducedMotion } from '@wordpress/compose';
import { useSelect } from '@wordpress/data';

/**
* Hook used to compute the styles required to move a div into a new position.
Expand All @@ -29,8 +28,7 @@ import { useSelect } from '@wordpress/data';
* @return {Object} Style object.
*/
function useMovingAnimation( ref, isSelected, enableAnimation, triggerAnimationOnChange ) {
const isTyping = useSelect( ( select ) => select( 'core/block-editor' ).isTyping() );
const prefersReducedMotion = useReducedMotion() || isTyping || ! enableAnimation;
const prefersReducedMotion = useReducedMotion() || ! enableAnimation;
const [ resetAnimation, setResetAnimation ] = useState( false );
const [ transform, setTransform ] = useState( { x: 0, y: 0 } );

Expand Down

0 comments on commit 357b53d

Please sign in to comment.