-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Fix issue no touch event on mobile #37234
Conversation
Hi @mrtuvn. Thank you for your contribution! Add the comment under your pull request to deploy test or vanilla Magento instance:
❗ Automated tests can be triggered manually with an appropriate comment:
Allowed build names are:
You can find more information about the builds here For more details, review the Code Contributions documentation. |
@magento run all tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
@magento run Integration Tests, Functional Tests CE, Functional Tests B2B, Functional Tests EE |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
@magento give me test instance |
Hi @mrtuvn. Thank you for your request. I'm working on Magento instance for you. |
Hi @mrtuvn, here is your Magento Instance: https://fbcfaa3464f382e6a29ca2d31449570c.instances-prod.magento-community.engineering |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔ Approved.
Failing tests look not related to changes from this PR.
@magento run all tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
@magento run all tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
The current patch with all these changes is not working. It's impossible to swipe the images.
|
thanks for feedbacks! But latest update also for video mixed case too (if your products have setup multiple images and also video from backend). Have you update with my latest one ? @cptX I try keep not changes fotorama as much as possible! In this PR contain |
I don't have videos so I cannot test. But because I have images and images were not sliding with your latest update I ended up using only this part of the patch... |
@magento give me test instance |
Hi @mrtuvn. Thank you for your request. I'm working on Magento instance for you. |
Hi @mrtuvn, here is your Magento Instance: https://fbcfaa3464f382e6a29ca2d31449570c.instances-prod.magento-community.engineering |
After cross check browser i recognised results seem different between chrome - firefox (with options no capture option). Both scenarios use mobile with force touch enabled (simulator) |
I was using firefox and I can ensure that swipe in mobile was not working when using the last patched fotorama.js file. The only patch that actually worked (and I have it in production now) is the patch @ line 1143 of the original code... It was like the rest changes in the file were blocking the change of the patch at line 1143. So for sure a complete test should be done including all senarios pc, mobile, images, videos etc... |
@cptX i have updated my code recently after your feedback. Give it a try if you need. Previous the patch i sent you works for images but it's not work well with mixed images-video case. I have changed some code after that. You can try the latest version in this merge and let me know the results. Have you try to add some video/youtube link combine with slide image product ? |
@@ -1140,7 +1153,13 @@ fotoramaVersion = '4.6.4'; | |||
|
|||
function addEvent(el, e, fn, bool) { | |||
if (!e) return; | |||
el.addEventListener ? el.addEventListener(e, fn, !!bool) : el.attachEvent('on' + e, fn); | |||
|
|||
const options = (Modernizr.passiveeventlisteners) ? { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just curiously do we actual need add passive for every dom element (or just add to body, window object) ? CC: @fredden
Can we add logic for check specific. Since browsers have updated a lot of changes and magento js system seem fall behind quite far
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
element window.document or window.document.body or window should be set passive false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at this page on developer.mozilla.org
, it seems that omitting 'passive' seems to be the best option as modern browsers* default the 'passive' option to a sensible value depending on the event.
* but not Safari. Safari seems to often lag when implementing features. For example, the 'loading=lazy' attribute for '<img>'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeap i think default passive enabled on safari and it's supported well
https://caniuse.com/passive-event-listener
only not support for retired IE browser
Well seem internal already have updated code so i will mark this PR as draft |
@mrtuvn, since the original issue already closed and marked as fixed, can we close this Pull Request? |
yeap let's close this one |
Description (*)
Delivery patch for recent fix fotorama js issue touch image in product details page.
Feel free to leave any review or comment any your thoughts
Excellent docs from mozilla
https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#improving_scrolling_performance_with_passive_listeners
Logic here
wheel -> passive true cause listener can't block page rendering while the user is scrolling
non wheel (mobile) -> passive false
object options with property passive will pass to event listener at third params
Related Pull Requests
Fixed Issues (if relevant)
Manual testing scenarios (*)
For image type
Also should Re-test for images-videos mixed case
Further tests
Go click on image to enter fullscreen mode
try next image and close fullscreen (X icon) expect works without problems
PC browser console no errors related with fotorama
Cross-browsers checklists
Questions or comments
Contribution checklist (*)