From 7f5ae12581aa76ff9ae2064008d5d120b60d08d3 Mon Sep 17 00:00:00 2001 From: Toby Rahilly Date: Wed, 25 Apr 2018 09:14:10 +1000 Subject: [PATCH] react-dnd-touch-backend: Add touchSlop, ignoreContextMenu and scrollAngleRanges options. (#25244) * Add touchSlop, ignoreContextMenu and scrollAngleRanges to the TouchBackendOptions type. * v4 --- types/react-dnd-touch-backend/index.d.ts | 16 +++++++++++++++- .../react-dnd-touch-backend-tests.ts | 4 ++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/types/react-dnd-touch-backend/index.d.ts b/types/react-dnd-touch-backend/index.d.ts index d8e1681f96..86ba0d1d10 100644 --- a/types/react-dnd-touch-backend/index.d.ts +++ b/types/react-dnd-touch-backend/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-dnd-touch-backend 0.3 +// Type definitions for react-dnd-touch-backend 0.4 // Project: https://github.com/yahoo/react-dnd-touch-backend#readme // Definitions by: Daniel Król , Janeene Beeforth // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -31,4 +31,18 @@ export interface TouchBackendOptions { * @deprecated replaced by delayTouchStart and delayMouseStart, but is still supported at present. */ delay?: number; + /** + * Specifies the pixel distance moved before a drag is signaled. Default 0. + */ + touchSlop?: number; + /** + * If true, prevents the contextmenu event from canceling a drag. Default false. + */ + ignoreContextMenu?: boolean; + /** + * Specifies ranges of angles in degrees that drag events should be ignored. This is useful when you want to allow + * the user to scroll in a particular direction instead of dragging. Degrees move clockwise, 0/360 pointing to the + * left. Default: undefined + */ + scrollAngleRanges?: ReadonlyArray<{ start?: number, end?: number }>; } diff --git a/types/react-dnd-touch-backend/react-dnd-touch-backend-tests.ts b/types/react-dnd-touch-backend/react-dnd-touch-backend-tests.ts index 3e77b52d78..dbf807a6a8 100644 --- a/types/react-dnd-touch-backend/react-dnd-touch-backend-tests.ts +++ b/types/react-dnd-touch-backend/react-dnd-touch-backend-tests.ts @@ -11,3 +11,7 @@ const dndComponentKeyboardEvents = ReactDnd.DragDropContext(TouchBackend({enable const dndComponentOldDelay = ReactDnd.DragDropContext(TouchBackend({delay: 300})); const dndComponentAllCurrentEvents = ReactDnd.DragDropContext(TouchBackend( {enableKeyboardEvents: true, enableMouseEvents: true, delayMouseStart: 100, delayTouchStart: 200})); +const dndComponentWithScrollAngleRanges = ReactDnd.DragDropContext(TouchBackend( + { scrollAngleRanges: [{ start: 0, end: 0 }, { start: 0 }, { end: 0 }] })); +const dndComponentWithTouchSlop = ReactDnd.DragDropContext(TouchBackend({ touchSlop: 0 })); +const dndComponentWithIgnoreContextMenu = ReactDnd.DragDropContext(TouchBackend({ ignoreContextMenu: true }));