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

Cant scroll past main image on mobile #50

Closed
Budapresst opened this issue Jul 25, 2018 · 12 comments
Closed

Cant scroll past main image on mobile #50

Budapresst opened this issue Jul 25, 2018 · 12 comments

Comments

@Budapresst
Copy link

Greetings..

I'm using the lens position setting and the hammer.js integration from your demo. My gallery is at the top of the page. When the page loads on mobile, there is no way to access the content under the gallery without scrolling through the gallery, but scrolling through the main image doesn't work. The only way to scroll past the gallery is to use the 5px of non-image space on either side of the image.

You can see the issue by checking out your own demos here: https://payalord.github.io/xZoom/ On your site, the galleries are not at the top of the page, so you can sort of "get a running start" and scroll right past them, but if you stop scrolling just above one of your galleries and then try to get going again withe the lead image being the first point of contact, then you should see the issue.

I'm testing on Android 5 btw, if it matters...

Any advice?

Thanks!

@payalord
Copy link
Owner

I think this happens because there is event attached on scroll for scale by default, which useful for desktop version. But for touch devices it is not useful completely, because on touch devices there is no mouse. So scale better to reattach to pinch gesture instead.
I will create an example today later in sandbox to illustrate this approach.

@Budapresst
Copy link
Author

Budapresst commented Jul 26, 2018 via email

@Budapresst
Copy link
Author

Budapresst commented Aug 3, 2018 via email

@payalord
Copy link
Owner

payalord commented Aug 4, 2018

I'm sorry, really had a lot of work to do this week.

@payalord
Copy link
Owner

payalord commented Aug 4, 2018

Will try on this weekend.

@Budapresst
Copy link
Author

Budapresst commented Aug 4, 2018 via email

@payalord
Copy link
Owner

payalord commented Aug 5, 2018

I have added example with Hammer.js version 2, to xzoom-sandbox repository here: https://github.com/payalord/xzoom-sandbox/tree/master/Hammer.jsV2

Which available to check and test now from mobile by this link: https://payalord.github.io/xzoom-sandbox/Hammer.jsV2/

To fix scroll issue, it is required to use touchAction, but unfortunately Hammers option touchAction is not working as declared, I tested it several times, need to report them about that, but this is another story. The only thing right now that is matter is this:

Chrome 35+, IE10+ and soon FireFox, support the touch-action property. This property tells the browser how to handle touches on an element. It improves the detection and experience of the gestures a lot, because it can prevent scrolling of the page without any JavaScript has to be executed, which can be too late in some cases.

Hammer uses a javascript fallback for this property when needed, so it is working with non-supporting browsers too. Still, on some (unpopular) devices the fallback might not work as good as the native support.

So i fixed scroll by manually adding touch-action: pan-x via jQuery to the required element on pan event.

Also this example is not prefect. Because the behaviour of how exactly must be done interaction with mobile gestures depends on developer preferences. In my example i decided to use approach like first tap is opening zoom, then pan available to move image inside zoom area and then second tap will close zoom.

@Budapresst
Copy link
Author

Budapresst commented Aug 5, 2018 via email

@payalord
Copy link
Owner

I assume that issue is fixed.

@Budapresst
Copy link
Author

Budapresst commented Aug 17, 2018 via email

@pflind
Copy link

pflind commented Sep 14, 2018

@payalord and @Budapresst, it looks like this fix does not work on Android, only iOS. I tested with Chrome 42 under an older Android version. Zoom is initiated but you can't see the lens or move the lens around, it is stuck in the top left corner.

@payalord
Copy link
Owner

Must be new version of hammer.js not working on old version of chrome. Need test with hammer.js v1.

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

No branches or pull requests

3 participants