Jump to content
Search Community

Force onDrag to Fire

mperitz test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts



I am working on assisting a colleague in automation testing of our product.  We use GSAP Draggable to drag a video in the x direction to close it.  The automation library he uses (Appium) has deprecated its "swipe" mimicking functionality, so it is up to me to write a javascript script to simulate the swipe event.  So far I have been able to simulate the drag start and drag end events by creating pointerdown and pointerup events and calling draggable.startDrag/endDrag with the pointer events as arguments (we have the Draggable class saved on our window - I use Draggable.get(element) to find the draggable instance).  I know this is working because the onPress, onDragStart, and onDragEnd events are firing.  However, I do not know how to simulate the dragging itself.  I must do this, because in our onDrag callback, we are changing state which the onDragEnd event uses to determine whether or not to close the video.  My question is, how can I force the onDrag event to fire?


Unfortunately I cant really reproduce this in a codepen because our code is not open source :(


I have tried using the draggable.drag() method, but that does not work....





Link to comment
Share on other sites

I wonder why you'd even need to involve Draggable at all in that scenario - why not just TweenMax.to() or something? (Meaning animate it). You could use an onStart/onUpdate/onComplete to trigger any updates that you need. Perhaps I'm just misunderstanding the question though. 

  • Like 2
Link to comment
Share on other sites

@GreenSock, we are using Draggable because we want the video to stay with the user's finger as they swipe it.  If they don't drag it far enough to the left, it will not close the video, but it will reset to its original position.  Maybe if I post the script I am using, it will help.  Here is a repl with my code: https://repl.it/repls/InsignificantSpottedConferences. Let me know if you need more comments - note that the code will not work if you run it.  It has to be run in the context of our product....


@OSUblake, I sent our test engineer that page, so we will see what he says


Thanks for the responses!

Link to comment
Share on other sites

Ah, I misread and thought you were just trying to simulate (visually) a drag without an actual drag (which in my head sounded like basically an animation). But you're trying to do testing, so you're saying it's important to make it literally act in the environment just as if a real person was pressing/dragging/releasing, and ensuring that Draggable responds accordingly. Right? 


If so, that sounds like a question for Appium. Draggable just relies on mouse/touch/pointer events to do its thing, so I'd guess that as long as you're firing those in the proper way to simulate the drag, it'd work fine. But I have noticed that certain environments (browsers) often won't allow you to simulate REAL mouse/touch/pointer events that are trusted (for security reasons). Thus I'm not 100% sure that what you're asking for is possible, at least in the browser. But perhaps Appium makes it possible. 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...