ngryman / jquery.finger

:v: jQuery touch & gestures, fingers in the nose.
https://ngryman.sh/jquery.finger/
MIT License
423 stars 66 forks source link

Prevent default but not vertical scrolling. #12

Open senner007 opened 11 years ago

senner007 commented 11 years ago

Whats the status on this?

I found a solution using hammer.js :

$('#container').hammer({drag_block_horizontal: true});

,but then I have to include this library for this funtionality only.

ngryman commented 11 years ago

Hi,

I will refactor all prevent default related stuff for the next release. There are some problems with the current implementation. I have to think about how to do this correctly.

By then, I will soon provide a simple patch to give access to the original event and let the user prevent it if he wants. With the patched version, something like this will solve your problem:

$('#slider').on('drag', function(e) {
  if ('vertical' == e.orientation) {
    return;
  }

  e.originalEvent.preventDefault();
  // do my stuff...
});
ngryman commented 11 years ago

Released a patched version : 79d58e6a818598f1c79f120a0f86cd5f78ef9f94.

senner007 commented 11 years ago

This does not seem to wok. I did as above but it does not block vertical scrolling.

ngryman commented 11 years ago

Ok. I will dig more deeply to find a satisfying solution for this.

ngryman commented 11 years ago

This release makes the code above work : https://github.com/ngryman/jquery.finger/releases/tag/v0.1.0-beta. Here is a live demo : http://jsfiddle.net/ngryman/dfgee/.

senner007 commented 11 years ago

It seems to be working now. The only problem is that the event is fired twice. ??? Also, it doesn't seem to work with the 'flick' event

ngryman commented 11 years ago

Ok, this is perhaps related to #13.

senner007 commented 11 years ago

Could be, although it doesn't seem to be android related. You can see for yourself in the fiddle example you made.

siddo420 commented 10 years ago

have you fixed this issue?