Browse Source

fix: background things get selected on Safari even while dragging

master
Muthu Kumar 2 months ago
parent
commit
7a8c7ca61d
Failed to extract signature
  1. 6
      src/draggable.attempts/6/Draggable.ts

6
src/draggable.attempts/6/Draggable.ts

@ -101,6 +101,9 @@ export function makeDraggable(card: HTMLElement, opts: DraggableOpts = {}) {
lastMousePosition = { x: e.pageX, y: e.pageY }; lastMousePosition = { x: e.pageX, y: e.pageY };
angularVelocity = 0; angularVelocity = 0;
document.body.style.userSelect = "none";
document.body.style.webkitUserSelect = "none";
}; };
const move = (e: PointerEvent) => { const move = (e: PointerEvent) => {
@ -151,6 +154,8 @@ export function makeDraggable(card: HTMLElement, opts: DraggableOpts = {}) {
state.dragging = false; state.dragging = false;
activePointerId = null; activePointerId = null;
card.style.cursor = "grab"; card.style.cursor = "grab";
document.body.style.userSelect = "auto";
document.body.style.webkitUserSelect = "auto";
// Momentum is handled in the render loop // Momentum is handled in the render loop
}; };
@ -239,7 +244,6 @@ export function makeDraggable(card: HTMLElement, opts: DraggableOpts = {}) {
card.style.cursor = "grab"; card.style.cursor = "grab";
card.style.touchAction = "none"; card.style.touchAction = "none";
card.style.userSelect = "none";
card.style.transform = `translate(0px, 0px) rotate(${rotation}rad)`; card.style.transform = `translate(0px, 0px) rotate(${rotation}rad)`;

Loading…
Cancel
Save