interact.js - how to fire dragstart programmatically

576 views Asked by At

I'm trying to start the drag of a draggable item after 1000ms of the touchstart event.

I was able to fire the "dragstart" event:

interact(element).fire({type: 'dragstart'});

but it just executes the function associated to the "start" event, it doesn't make the item draggable.

My goal is to create a trello-style interface with scrollable droparea-columns containing draggable cards. I already know there's a "hold" parameter, but I think I can't use it because during the 1000ms other gestures (like scroll) on the draggable items seem disabled.

Thanks.

1

There are 1 answers

0
enne87 On

Not sure if this is exactly what you need, but you can start a drag by triggering the 'down' event:

interact(element).on('down', event => {
 event.interaction.start({ name: 'drag' }, 
 event.interactable, 
 event.currentTarget);
});