Jump to content
Search Community

How to detect if i'm dragging up or down??

celopez16 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

PointC I'd like to talk about another question, something a little bit weird, if you drag an element and you drag it fast, the actions that you execute in the "onDrag" event for example, behave different than if you drag slowly. I have a site where i use Draggable to zoom in or out a photo, in the event "onDrag" I increase the size depending on the direction of the element, but i notice that when I move it really fast, the size is smaller, but if I drag slowly, the image increases more. What could be going on here? Thanks

Link to comment
Share on other sites

Hi Celopez,


Not sure I understand what you are experiencing.

It really helps if you can create a reduced test case using CodePen: http://greensock.com/forums/topic/9002-read-this-first-how-to-create-a-codepen-demo/


Also, questions can easily get overlooked if you follow up an already answered question with a new one. I imagine many of us saw that PointC answered your first question perfectly and didn't know that something new came in. The best thing is to put new questions in a new thread. No worries.

  • Like 1
Link to comment
Share on other sites

Yep - I missed this follow up question. 


I'm with Carl - I'm not sure I completely understand what you're describing. If we can get a look at your onDrag function, I'm sure we can point you in the right direction. Please let us know when you have a CodePen available. Thanks.

Link to comment
Share on other sites

Thanks PointC and Carl, is really simple y have a draggable element, like the zoom of google maps, I detect if the user is zooming in or zooming out, sp I use the getDirection() method, the funny thing is, for example if you have a counter in the onDrag event, the counter will end up with a low number, say (10) if you drag fast, but if you drag slow, the number may be 50, I hope it's clear (i dont know mucho about codepen) :D Thanks!:

type: "y",
bounds: $("#labarra"),
onClick:function() {
onDragEnd:function() {
/*if(direccion=="up") TweenMax.to("#elscroll img", 0.3, {width:"200%"});
else TweenMax.to("#elscroll img", 0.3, {width:"70%"});*/
porcent=($('#elscroll img').width() / w_contenedor) * 100
if(porcent<200) TweenMax.to("#elscroll img", 0.1, {width:( $('#elscroll img').width()+30 )});
if(porcent>=70) TweenMax.to("#elscroll img", 0.1, {width:( $('#elscroll img').width()-30 )});
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...