- This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
Viewing 7 posts - 1 through 7 (of 7 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › Triggering a wheel event on mobile
Will mobile browsers know what this event is when it is triggered like this?
$(window).trigger('mousewheel');
Obviously it won’t be able to listen for the manual event when it has no mouse but from what I can find (not a lot) it should not be an unknown event to Safari. That would mean that if you trigger it (without a mouse), you’d still be able to do stuff with it.
This real or am I just wacko to think so?
I really think I need a (or any) mobile device to test stuff on…
But from what I read on the Apple page, wheel
events are part of the mobile API. And can even be triggered without a mouse :
If the user holds two fingers down on a scrollable element and moves the fingers, mousewheel events are generated.
Back to the mental drawing board…
Short answer, yes.
var triggers = 0;
$(document).on('mousewheel', function(e) {
$('.count').text(++triggers);
});
$(document).on('touchmove', function() { //touchmove works for iOS, I don't know if Android supports it
$(document).trigger('mousewheel');
});
Tested it here on iPad/iPhone:
http://codepen.io/ilanf/pen/mJBdgL/
Neat, thanks for the feedback and making that demo. B-)
That’ll give some interesting new use for the event. They should really trigger a wheel
instead though to join the more common (modern) term. But it’s good stuff in any case.
It is nice and helped me lot, but i had an issue, Is it possible to find touch move is happening in the direction of top to bottom or bottom to top??
Have a look at the lower part of my answer here:
There also this library which adds common gesture events. Give this a try
http://hammerjs.github.io