Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/busy-socks-brake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@dnd-kit/dom': patch
---

Check touch-action CSS property before allowing touch-based dragging
15 changes: 13 additions & 2 deletions packages/dom/src/core/sensors/pointer/PointerSensor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from '@dnd-kit/abstract';
import type {Coordinates} from '@dnd-kit/geometry';
import {
getComputedStyles,
getDocument,
getDocuments,
getEventCoordinates,
Expand Down Expand Up @@ -73,6 +74,16 @@ const defaults = Object.freeze<PointerSensorOptions>({
preventActivation(event, source) {
const {target} = event;

if (event.pointerType === 'touch') {
const activator = source.handle ?? source.element;
if (activator) {
const touchAction = getComputedStyles(activator).touchAction;
if (touchAction !== 'none') {
return true;
}
}
}

if (target === source.element) return false;
if (target === source.handle) return false;
if (!isElement(target)) return false;
Expand Down Expand Up @@ -115,8 +126,8 @@ export class PointerSensor extends Sensor<
}

protected activationConstraints(
event: PointerEvent,
source: Draggable,
event: PointerEvent,
source: Draggable,
options = this.options
) {
const {activationConstraints = defaults.activationConstraints} =
Expand Down
Loading