Share Posted May 27, 2015 Hello.. 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"), { type:'y', lockAxis:true, onRelease:function() { var dir = this.getDirection("start"); console.log('swipe! onDragStart() ' + dir) if (dir === "up"){ next(); }else if(dir === "down"){ prev(); } } }); ALSO, I tried attaching it to the body, but the only direction that would log was "right". Thanks, Link to comment Share on other sites More sharing options...
Share Posted May 27, 2015 Hi HaunGo pls try this : var D = document.createElement('div'); Draggable.create(D,{ type:'y', lockAxis : true , trigger:$("#stage"), onDragEnd:function(){ console.log( this.getDirection("start") == "up" ? 'next' : 'back' ); } }); 2 Link to comment Share on other sites More sharing options...
Author Share Posted May 27, 2015 This works great Diaco THANKS ! Now, I'll figure out WHY it works. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now