How to test draggable object programmatically
See original GitHub issueI’m trying to unit test some functionality related to dragging on my site; I use interact like this:
interact(element).draggable({ onstart: functionToTest })
I’m trying to simulate a drag by manually triggering events with jQuery:
$(element).mousedown(); ...
But it seems that interact doesn’t respond to these manual triggers at all. Am I doing something wrong here?
Issue Analytics
- State:
- Created 9 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Drag object programmatically - javascript - Stack Overflow
This should get you fairly close, if I understood you correctly. Click anywhere inside the black square of the canvas and outside the...
Read more >How to write better tests for drag-and-drop operations in the ...
We need to set the clientX and clientY properties of the event, because they are used to determine the direction of the dragging....
Read more >Draggable - How to start dragging programmatically
Hi team, We need to be able to drag an item from a dev-ex scheduler (scheduler2) (which is in a separate browser window)...
Read more >Controlling Draggable programmatically - GSAP - GreenSock
Draggable.create() returns an Array of Draggable instances (remember, you may pass in selector text that'd match many elements, thus a Draggable ...
Read more >How to test drag-and-drop interactions in Playwright - Reflect.run
To make the script works, you have to call the dragTo() function on the same source and target sliderHandle element. Also, the flag...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
$(element).mousedown()
doesn’t fire event listeners that were added withNode.addEventListener
which is used by interact.js. You would have to create and trigger events manually.But you can just use
interactable.fire(eventObject)
to call the listeners foreventObject.type
.@taye and others who might be trying the same thing, I found out how to do it. Interact.js actually listens to PointerEvents, not MouseEvents, and it listens for them on document, not the element itself, so it needs to bubble.