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.

Drag starts on press instead of long press

See original GitHub issue

Hi, I’m trying to use this library to create a scrollable SectionList. So far I can drag the section headers and the items, but I have a problem because the drag starts as soon as I touch the screen i.e. on press instead of long press, so I can’t scroll the list unless I comment out “onDragStart={() => {console.log(“drag item”);}}”

The drag is supposed to start on long press by default. How do I force that? Any workarounds?

If I use DraxView on a smaller part of the UI e.g. an icon or image in the section or list item, that fixes the problem, but then the UI of what gets dragged is just the icon or image instead of the entire section or list item. Is there a way to specify the UI that gets dragged?

Note: It would also be nice to be able to drag the whole section UI, and not just the section header, but I tried that and it didn’t work. I used nested DraxViews.

Using: “react-native”: “0.68.2”, “react-native-gesture-handler”: “~2.2.1”,

The basic structure is:

<DraxProvider>
 <View>
  <DraxScrollView>
   {this.props.Items.map((section) => (
    <View>
     <DraxView payload={section} onDragStart={() => {console.log("drag section");}}>
	  <Text>{section.Title}</Text>
	 </Draxview>
     {section.map((item) => (
      <DraxView payload={item} onDragStart={() => {console.log("drag item");}}>
       <Text>{item.Title}</Text>
	  </Draxview>
     ))}
    </View>
   ))}
  <DraxScrollView>
 <View>
</DraxProvider>

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
tomgiamcommented, Sep 22, 2022

@lafiosca Thanks, DraxSnapbackTargetPreset.None works!. I did notice one other issue. The first few drag drops work correctly, but then the drag image initial display location is not over the image being dragged, but 100-200 pixels above or below it. This fixes itself if I refresh the screen (e.g. navigate away and back).

0reactions
lafioscacommented, Sep 23, 2022

If this offset behavior is consistently wrong and can be reproduced in a simple project or snack, please open a separate issue to track it. (I don’t want to get your hopes up though, as I will not personally have time to look into it… but at least if there is an issue open, people can be aware and someone may investigate further.)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Drag after long press - Stack Overflow
As the mouse is pressed and hold the drag.target is set and drag can start, whereas when the mouse is released the drag.target...
Read more >
SwiftUI Gestures (Long Press, Drag, Tap) - YouTube
We will look at drag and long press gestures in particular. We will work with the latest version of Xcode and SwiftUI.
Read more >
Gestures | Jetpack Compose - Android Developers
The draggable modifier is the high-level entry point to drag gestures in a single orientation, and reports the drag distance in pixels. ......
Read more >
[iOS 13] Long press and drag to select #35010 - GitHub
In iOS 13, long pressing on editable and non-editable text starts selecting. Dragging extends the selection. I think this is identical to ...
Read more >
Basic Drag-n-Drop in Jetpack Compose - ProAndroidDev
Drag on Long-press. LazyList acts similar to RecyclerView, where reordering of data doesn't reorder the View instances, instead recycles to ...
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