Jump to content


Basic swipe event to call a function

Go to solution Solved by Diaco,

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'm having trouble finding a very basic swipe example.. ..  I don't need to drag anything around.. .. I just need to listen to a swipe up or down and call the appropriate function.


I've got a little something now based off of some examples, but again.. .. i end up dragging the stage round when I just want to listen for a swipe direction.


Any suggestions?


Here is my simple code:

var DD = Draggable.create($("#stage"),
		var dir = this.getDirection("start");
		console.log('swipe! onDragStart() ' + dir)
		if (dir === "up"){
		}else if(dir === "down"){



ALSO, I tried attaching it to the body, but the only direction that would log was "right".



Link to comment
Share on other sites

  • Solution

Hi HaunGo  :)


pls try this :


var D = document.createElement('div');
  lockAxis : true ,
    console.log( this.getDirection("start") == "up" ? 'next' : 'back' );
  • Like 2
Link to comment
Share on other sites

This works great Diaco   THANKS !



Now, I'll figure out WHY it works.  ;)    

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.