Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS 10: Page scrolling not disabled anymore #973

Open
saschanos opened this issue Oct 10, 2016 · 18 comments
Open

iOS 10: Page scrolling not disabled anymore #973

saschanos opened this issue Oct 10, 2016 · 18 comments

Comments

@saschanos
Copy link

When trying to sort items, on Apple iOS 10 the page is scrolling - even on your example page. Is there any solution for this problem? Regards from Germany.

@saschanos
Copy link
Author

maybe also have a look here:
http://www.openradar.me/28359335

@supercranky
Copy link

I had the same problem, it seems like it's working if you add

document.ontouchmove = function(e){
    return true;
};

Maybe it just needs a default ontouchmove handler

@saschanos
Copy link
Author

Hey @supercranky, looks better but not perfect - page sometimes scrolls in landscape mode. Found some other links regarding this issue:

@smathson
Copy link

@supercranky Any idea why this works? Trying to figure out if there are any side effects from adding a global ontouchmove handler.

@supercranky
Copy link

@smathson No idea really. Something must have changed in the inner workings of the browser :)

@saschanos
Copy link
Author

jQuery UI and his drag functions do work under iOS 10 (also in older versions). Maybe we can have a look where's the difference between the code of this module and jQuery UI?!

@smathson
Copy link

@saschanos Which jQuery UI drag functions work in iOS 10? Doesn't look like any code deals with touch and the demo site doesn't work in iOS as far as I can tell.

@saschanos
Copy link
Author

Have a look at that website: https://www.date-your-career.de/fragebogen. Click the first option multiple times until you reach the question where you can see draggable elements. These elements are working perfectly on iOS 10 and it was realized by jQuery UI and jQuery UI Touch Punch.

@smathson
Copy link

Got it, so it's the Touch Punch plugin that's handling the touches. Looks like it works by handling the touch events and converting them to the corresponding mouse events.

@RubaXa
Copy link
Collaborator

RubaXa commented Feb 19, 2017

Try master.

@matthornsby
Copy link

I'm having a similar issue on master in ios11 in my local project but can't replicate on any of your demos. I suspect there must be some setting i'm missing.

@kaido24
Copy link

kaido24 commented Dec 11, 2017

Also some issues with IOS 11 scroll.

@MChartier
Copy link

The example @supercranky provided didn't work for me with iOS 11.3, but this did:

window.addEventListener('touchmove', (e) => {
return;
}, { passive: false });

@rainboxx
Copy link

@MChartier Where did you add this? Trying to verify whether this could work for us as well.


Edit: sorry, turned out that we had an older version fixed with the package-lock.json as a dependency of the legacy AngularJS package. Updating fixed the issue for iOS 11: master is checking for passive mode etc. which seems to be the root cause for this issue.

@jimpant
Copy link

jimpant commented Jun 23, 2018

@MChartier Thank you! You comment also helped my situation in an e-shop with various carousels!

@etiennetalbot
Copy link

Hi everyone... I noticed a performance problem while scrolling my app on older android devices. When sortable.js is included, scrolling becomes janky app-wide. I found that the problem was this bit of code here:

_on(document, 'touchmove', function (evt) {
	if (Sortable.active) {
		evt.preventDefault();
	}
});

I get why it's there (iOS problem and all) but, I mean, wouldn't it be better if the event listener was only created on touchstart of a sortable item, and then deleted on touchend of that sortable item?
Or maybe just do it the other way around... since clearly we only need this when Sortable.active is defined, why not set the listener when it becomes defined and clear it when it's nulled?

Otherwise when checking with the Chrome devtools' Rendering > Scrolling performance issue tab, we get this all the time:
screen shot 2018-07-20 at 08 59 50

And it does affect scrolling performance...
What do you think?

@Exocomp
Copy link

Exocomp commented Jan 26, 2021

I noticed the global touchmove while doing performance profiling, I see the same thing that @etiennetalbot mentioned.

This seems like a hack to just globally listen on touchmove.

// Fixed #973:
if (documentExists) {
	on(document, 'touchmove', function(evt) {
		if ((Sortable.active || awaitingDragStarted) && evt.cancelable) {
			evt.preventDefault();
		}
	});
}

I only use sortablejs on one component (Angular) but on every component now I see sortable touchmove in the profiler timeline. So it is running for no reason for the components which are not using sortablejs. It should only be enabled when necessary where sortablejs is used that would be ideal.

@Antti
Copy link

Antti commented Feb 18, 2021

Any updates on this?
The only workaround (without forking this lib) is to require sortable only when needed, and not just import lib as normal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests