question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Re-usable drag handle example

See original GitHub issue

Hey, I’ve created a somewhat more re-usable drag handle example based on the example from the readme: REPL

The usage is simple:

const { dragHandleZone, dragHandle } = createDragHandle();
// on drag zone
use:dragHandleZone={{ /** dndzone options **/ }}
  
// on drag handle
use:dragHandle

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
isaacHagoelcommented, Dec 15, 2021

@zahachtah good catch. the official example (no action) had the same issue. the fix is to add mouseup and touchend listeners to the handle and have them disable drag. the same solution should work for the action. i will fix when i have a chance

0reactions
benbrocommented, Dec 21, 2022

I’m trying to use this action with nested zones. There is a parent list of items - zone-0. Each item has a list of sub-items - separate zone-n for each sub-items list. I thought of adding a type parameter to the dragHandle action and make the drag store a Set of drag-able types. Did anyone extend this action to support multiple zones and nested zones?

const drag = writable(new Set());

function dragHandle(node, type) {
    function startDrag(e) {
        // preventing default to prevent lag on touch devices (because of the browser checking for screen scrolling)
        e.preventDefault();
        $drag = $drag.add(type);
    }
}
<button use:dragHandle={{type: 'zone1'}}>
<button use:dragHandle={{type: 'zone2'}}>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Example of making a reusable `draggable()` modifier for ...
Example of making a reusable `draggable()` modifier for SwiftUI Views - DraggableView.swift. ... Handle dragging. struct DraggableView: ViewModifier {.
Read more >
Making of: draggable handles - Red Blob Games
I can have a separate function that takes the internal variable and sets the circle position. Let's try this with a simple example:...
Read more >
How to Make a Simple Custom useDrag React Hook
Build a custom UI component with React's useEffect hook to control dragging behavior on HTML elements without third party libraries.
Read more >
Draggable Reusable JavaScript Panel - CodeProject
Reusable draggable JavaScript panel with dynamic content. ... The draggable panel handles the click events, drag and minimize functionality.
Read more >
Create an Easy Custom React Hook for Dragging Components
That's why today I'm going to work with you and help you build your own reusable hook to create draggable components.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found