File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed
Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change 44 * SPDX-License-Identifier: Apache-2.0
55 */
66
7- import { dragging } from 'blockly' ;
7+ import { dragging , utils } from 'blockly' ;
8+ import { Direction , getDirectionFromXY } from './drag_direction' ;
89
910export class KeyboardDragStrategy extends dragging . BlockDragStrategy {
11+ private currentDragDirection : Direction | null = null ;
12+
1013 override startDrag ( e ?: PointerEvent ) {
1114 super . startDrag ( e ) ;
1215 // Set position of the dragging block, so that it doesn't pop
1316 // to the top left of the workspace.
1417 // @ts -expect-error block and startLoc are private.
1518 this . block . moveDuringDrag ( this . startLoc ) ;
1619 }
20+
21+ override drag ( newLoc : utils . Coordinate , e ?: PointerEvent ) : void {
22+ if ( ! e ) return ;
23+ this . currentDragDirection = getDirectionFromXY ( { x : e . tiltX , y : e . tiltY } ) ;
24+ super . drag ( newLoc ) ;
25+ }
26+
27+ /**
28+ * Get whether the most recent drag event represents a constrained
29+ * keyboard drag.
30+ *
31+ * @returns true if the current movement is constrained, otherwise false.
32+ */
33+ private isConstrainedMovement ( ) : boolean {
34+ return ! ! this . currentDragDirection ;
35+ }
1736}
You can’t perform that action at this time.
0 commit comments