Skip to content

Commit

Permalink
Remove useScrollWhenDragging hook
Browse files Browse the repository at this point in the history
This hook will be introduced in a separate PR
  • Loading branch information
fluiddot committed Mar 23, 2022
1 parent ba2b875 commit ff1b9dd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 145 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { useEffect } from '@wordpress/element';
/**
* Internal dependencies
*/
import useScrollWhenDragging from './use-scroll-when-dragging';
import DraggableChip from './draggable-chip';
import { store as blockEditorStore } from '../../store';
import { useBlockListContext } from '../block-list/block-list-context';
Expand Down Expand Up @@ -65,19 +64,10 @@ const BlockDraggableWrapper = ( { children } ) => {
const isDragging = useSharedValue( false );
const scrollAnimation = useSharedValue( 0 );

const [
startScrolling,
scrollOnDragOver,
stopScrolling,
draggingScrollHandler,
] = useScrollWhenDragging();

const scrollHandler = ( event ) => {
'worklet';
const { contentOffset } = event;
scroll.offsetY.value = contentOffset.y;

draggingScrollHandler( event );
};

// Stop dragging blocks if the block draggable is unmounted.
Expand Down Expand Up @@ -110,13 +100,9 @@ const BlockDraggableWrapper = ( { children } ) => {
( scroll.offsetY.value - blockLayout.y ) -
EXTRA_OFFSET_WHEN_CLOSE_TO_TOP_EDGE
);
scrollAnimation.value = withTiming(
scrollOffsetTarget,
{ duration: SCROLL_ANIMATION_DURATION },
() => startScrolling( position.y )
);
} else {
runOnUI( startScrolling )( position.y );
scrollAnimation.value = withTiming( scrollOffsetTarget, {
duration: SCROLL_ANIMATION_DURATION,
} );
}
}
};
Expand Down Expand Up @@ -164,9 +150,6 @@ const BlockDraggableWrapper = ( { children } ) => {

chip.x.value = dragPosition.x;
chip.y.value = dragPosition.y;

// Update scrolling velocity
scrollOnDragOver( dragPosition.y );
};

const stopDragging = () => {
Expand All @@ -175,7 +158,6 @@ const BlockDraggableWrapper = ( { children } ) => {

chip.scale.value = withTiming( 0 );
runOnJS( stopDraggingBlocks )();
stopScrolling();
};

const chipStyles = useAnimatedStyle( () => {
Expand Down

This file was deleted.

0 comments on commit ff1b9dd

Please sign in to comment.