You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 10, 2024. It is now read-only.
From my limited to reading on the matter, for elements that are not links or buttons, iOS doesn’t translate click events to ontouchstart; therefore touching outside the menu doesn’t work in iOS.
The text was updated successfully, but these errors were encountered:
Problem is that it will probably cancel any attempts to scroll vertically if the user touches the right-hand side (i.e. not the nav element). You'd want a slight delay to ensure the touchend, touchcancel or mouseup happen within 200–300ms.
In the past when working with dropdown-type interface elements I've implemented this functionality (modified to make sense here) to best-guess whether or not a user is scrolling:
$(document).on('click touchstart touchend', function(e) {
var touch;
var sensitivity = 20;
var closeThis = function() {...};
// Distinguish scroll from a 'tap'
if ( e.type === 'touchstart' && e.originalEvent.touches.length === 1 ) {
touch = {
x: e.originalEvent.touches[0].pageX,
y: e.originalEvent.touches[0].pageY
};
return;
}
if ( e.type === 'touchend' ) {
var difX = Math.abs(touch.x - e.originalEvent.changedTouches[0].pageX);
var difY = Math.abs(touch.y - e.originalEvent.changedTouches[0].pageY);
touch = undefined;
if ( difX > sensitivity || difY > sensitivity ) {
return;
}
}
closeThis();
});
EDIT: I guess this is actually simpler but I seem to remember changedTouches is/was a bitch:
From my limited to reading on the matter, for elements that are not links or buttons, iOS doesn’t translate click events to ontouchstart; therefore touching outside the menu doesn’t work in iOS.
The text was updated successfully, but these errors were encountered: