Sha256: ebec339d86e838e36c9ee3334eeb8a2e6152b0a22f34663f3a021986c540e93a

Contents?: true

Size: 391 Bytes

Versions: 15

Compression:

Stored size: 391 Bytes

Contents

import { useEffect, useRef } from "react";

export default function useDraggable(draggable, startDrag) {
  const ref = useRef();

  const handleDrag = (evt) => {
    evt.preventDefault();
    evt.stopPropagation();
    startDrag(evt, draggable);
  };

  useEffect(() => {
    draggable.ref.current = ref.current;
  }, []);

  return { ref: ref, onDragStart: handleDrag, draggable: true };
}

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
pages_core-3.12.1 app/javascript/components/drag/useDraggable.js
pages_core-3.12.0 app/javascript/components/drag/useDraggable.js
pages_core-3.11.3 app/javascript/components/drag/useDraggable.js
pages_core-3.11.2 app/javascript/components/drag/useDraggable.js
pages_core-3.11.1 app/javascript/components/drag/useDraggable.js
pages_core-3.11.0 app/javascript/components/drag/useDraggable.js
pages_core-3.10.2 app/javascript/components/drag/useDraggable.js
pages_core-3.10.1 app/javascript/components/drag/useDraggable.js
pages_core-3.9.2 app/javascript/components/drag/useDraggable.js
pages_core-3.9.1 app/javascript/components/drag/useDraggable.js
pages_core-3.9.0 app/javascript/components/drag/useDraggable.js
pages_core-3.8.3 app/javascript/components/drag/useDraggable.js
pages_core-3.8.2 app/javascript/components/drag/useDraggable.js
pages_core-3.8.1 app/javascript/components/drag/useDraggable.js
pages_core-3.8.0 app/javascript/components/drag/useDraggable.js