This fiddle is an example of how mobile Safari has a bug in that developers cannot stop a native scroll event from happening. And, if there's a override to the touch event on an object, the scroll event won't start unless there's some delay to the touch event.
var self = this;
var supportsTouch = (('ontouchstart' in window) || window.DocumentTouch && document instanceof window.DocumentTouch);
//
// There's no way to cancel the scrolling events that are
// native in the iOS Safari browser.
//
//
// List 1 - Scrolling can never happen when swiping over this list.
//
$('#list1 .list-item').on('touchstart mousedown', function (event) {
self.preventDefault = true;
self.draggingTarget = event.target;
self.startPageX = event.pageX;
self.startPageY = event.pageY;
if (event.type == 'touchstart') {
self.startPageX = event.originalEvent.touches[0].pageX;
self.startPageY = event.originalEvent.touches[0].pageY;
}
});
$('#list1 .list-item').on('touchend mouseup', function (event) {
self.preventDefault = false;
self.draggingTarget = null;
updatePosition(event.target, 0, 0);
});
//
// List 2 - Scrolling can happen when swiping over this list and
// when it does, it can't be stopped.
//
$('#list2 .list-item').on('touchstart mousedown', function (event) {
self.preventDefault = false;
self.draggingTarget = event.target;
self.startPageX = event.pageX;
self.startPageY = event.pageY;
if (event.type == 'touchstart') {
self.startPageX = event.originalEvent.touches[0].pageX;
self.startPageY = event.originalEvent.touches[0].pageY;
}
});
$('#list2 .list-item').on('touchend mouseup', function (event) {
self.preventDefault = false;
self.draggingTarget = null;
updatePosition(event.target, 0, 0);
});
//
// Handle the drag events.
//
$(document).on('touchmove mousemove', function (event) {
var x = event.pageX - self.startPageX;
var y = event.pageY - self.startPageY;
if (event.type == 'touchmove') {
x = event.originalEvent.touches[0].pageX - self.startPageX;
y = event.originalEvent.touches[0].pageY - self.startPageY;
}
if (self.draggingTarget) {
updatePosition(self.draggingTarget, x, y);
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Fiddle Pages
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Get Fiddle Pages with PRO
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.