davetayls / jquery.kinetic

Add kinetic scrolling functionality to a container using mouse or touch devices
http://davetayls.me/jquery.kinetic
MIT License
420 stars 86 forks source link

Avoid clicking while moving #80

Closed joaodelfino closed 9 years ago

joaodelfino commented 9 years ago

Hi, I have a grid of links over my wrapper. When I move the image this grid moves also, but it also triggers the click for the links... Is there any way to avoid it ? I've tried the filterTarget but withou success. ( take a look at the screenshot, white squares are the links ). Thanks a lot ! capture

davetayls commented 9 years ago

Do you mean that everything inside the scrollable window is a link and you only want to click it if you haven't moved the mouse while the button is down?

joaodelfino commented 9 years ago

Yes, that about it. Each square is a different link and the squares occupy all the scrollable window. Em 21/04/2015 06:47, "Dave Taylor" notifications@github.com escreveu:

Do you mean that everything inside the scrollable window is a link and you only want to click it if you haven't moved the mouse while the button is down?

— Reply to this email directly or view it on GitHub https://github.com/davetayls/jquery.kinetic/issues/80#issuecomment-94646835 .

joaodelfino commented 9 years ago

And yes, you're right, I only want those links to be clickable when I haven't move the mouse while the button is down. Em 21/04/2015 06:47, "Dave Taylor" notifications@github.com escreveu:

Do you mean that everything inside the scrollable window is a link and you only want to click it if you haven't moved the mouse while the button is down?

— Reply to this email directly or view it on GitHub https://github.com/davetayls/jquery.kinetic/issues/80#issuecomment-94646835 .

davetayls commented 9 years ago

Ok, I would probably use filter target to prevent the click but capture the current element. Then use stopped to check how far it has moved, if it has moved over a particular distance trigger a click on the element captured

joaodelfino commented 9 years ago

Thanks.

alexandar87 commented 3 years ago

@davetayls can you provide a code snippet for your previous statement. I'm having a hard time disabling links while moving, the moment I release the button and stop moving, it opens a link.

alexandar87 commented 3 years ago

@davetayls can you provide a code snippet for your previous statement. I'm having a hard time disabling links while moving, the moment I release the button and stop moving, it opens a link.

I found a workaround if someone needs it:


      moved: function() {
        $('.wp-my-instagram a').bind('click', function(e){
          e.preventDefault();
        });
      },
      stopped: function() {
        setTimeout(function(){
          $('.wp-my-instagram a').unbind('click'); },
          100);
      }
    });