fix: fixed scrolling by draggable on mobile
This commit is contained in:
@ -1,33 +1,28 @@
|
||||
import {
|
||||
KeyboardSensor,
|
||||
PointerSensor,
|
||||
MouseSensor,
|
||||
TouchSensor,
|
||||
useSensor,
|
||||
useSensors,
|
||||
} from "@dnd-kit/core";
|
||||
import { sortableKeyboardCoordinates } from "@dnd-kit/sortable";
|
||||
import useIsMobile from "@/hooks/useIsMobile";
|
||||
|
||||
const useDndSensors = () => {
|
||||
const isMobile = useIsMobile();
|
||||
|
||||
const sensorOptions = {
|
||||
activationConstraint: isMobile
|
||||
? {
|
||||
delay: 500,
|
||||
tolerance: 5,
|
||||
}
|
||||
: {
|
||||
distance: 5,
|
||||
},
|
||||
};
|
||||
|
||||
return useSensors(
|
||||
useSensor(PointerSensor, sensorOptions),
|
||||
useSensor(MouseSensor, {
|
||||
activationConstraint: {
|
||||
distance: 8,
|
||||
},
|
||||
}),
|
||||
useSensor(KeyboardSensor, {
|
||||
coordinateGetter: sortableKeyboardCoordinates,
|
||||
}),
|
||||
useSensor(TouchSensor, sensorOptions)
|
||||
useSensor(TouchSensor, {
|
||||
activationConstraint: {
|
||||
delay: 300,
|
||||
tolerance: 5,
|
||||
},
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user