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

Prevent page scroll jumping when product gallery loads #25385

Merged

Conversation

krzksz
Copy link
Contributor

@krzksz krzksz commented Oct 30, 2019

Description (*)

During the investigation of the issue linked below I was able to pinpoint the exact moment of scroll jumping to fotorama's that.resize function which for some reason resets all of its major elements' width and height dimensions. I analysed the code and concluded that since current element height seems to be completely ignored in the whole script and is only set either based on settings or its width and ratio, the code that resets it can be removed. Please not that this can be also true for width but I left it here just to be safe as it doesn't contribute to page jumping.

In addition, min-height was added to prevent initial jump of the gallery when static image is being replaced by fotorama's HTML.

Fixed Issues (if relevant)

  1. Mobile product page image jumps #10518: Mobile product page image jumps
  2. Product view page scrolls up randomly on mobile device #21717: Product view page scrolls up randomly on mobile device

Manual testing scenarios (*)

  1. Open product page with images in the gallery in mobile view.
  2. Scroll to the middle of the static image before gallery loads.
  3. Page should no longer jump to the top once gallery initializes.

Questions or comments

Please be sure to test this change on multiple browsers and devices including resizing the window through different resolutions as fotorama's configuration changes between breakpoins.

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

During the investigation of the issue linked below I was able to pinpoint the exact moment of scroll jumping to fotorama's `that.resize` function
which for some reason resets all of its major elements' width and height dimensions. I analysed the code and concluded that since current element
height seems to be completely ignored in the whole script and is only set either based on settings or its width and ratio, the code that resets it
can be removed. Please not that this can be also true for width but I left it here just to be safe as it doesn't contribute to page jumping.

In addition, `min-height` was added to prevent initial jump of the gallery when static image is being replaced by fotorama's HTML.

Fixes magento#10518.
@krzksz krzksz requested a review from DrewML as a code owner October 30, 2019 20:24
@m2-assistant
Copy link

m2-assistant bot commented Oct 30, 2019

Hi @krzksz. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.3-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Guide documentation.

@rodrigowebjump
Copy link
Member

@magento give me test instance

@magento-engcom-team
Copy link
Contributor

Hi @rodrigowebjump. Thank you for your request. I'm working on Magento instance for you

@magento-engcom-team
Copy link
Contributor

Hi @rodrigowebjump, here is your new Magento instance.
Admin access: https://pr-25385.instances.magento-community.engineering/admin
Login: admin Password: 123123q

@rodrigowebjump
Copy link
Member

@magento give me 2.3-develop instance

@magento-engcom-team
Copy link
Contributor

Hi @rodrigowebjump. Thank you for your request. I'm working on Magento 2.3-develop instance for you

@magento-engcom-team
Copy link
Contributor

Hi @rodrigowebjump, here is your Magento instance.
Admin access: https://i-25385-2-3-develop.instances.magento-community.engineering/admin
Login: admin Password: 123123q
Instance will be terminated in up to 3 hours.

Copy link
Member

@rodrigowebjump rodrigowebjump left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @krzksz

Thanks for your contribution

@magento-engcom-team
Copy link
Contributor

Hi @rodrigowebjump, thank you for the review.
ENGCOM-6376 has been created to process this Pull Request
✳️ @rodrigowebjump, could you please add one of the following labels to the Pull Request?

Label Description
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests
Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests
Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests

@sidolov sidolov changed the base branch from 2.3-develop to 2.4-develop December 5, 2019 17:16
@krzksz
Copy link
Contributor Author

krzksz commented Dec 12, 2019

@magento run all tests

@engcom-Delta
Copy link
Contributor

Hi @krzksz Please cover your fix with unit test

@engcom-Delta engcom-Delta added the Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests label Dec 17, 2019
@engcom-Golf engcom-Golf self-assigned this Jan 21, 2020
@engcom-Golf
Copy link
Contributor

I will take care of test coverage

@engcom-Golf
Copy link
Contributor

@magento run all tests

@engcom-Golf engcom-Golf added Auto-Tests: Covered All changes in Pull Request is covered by auto-tests and removed Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests labels Jan 21, 2020
@magento-engcom-team
Copy link
Contributor

Hi @rodrigowebjump, thank you for the review.
ENGCOM-6376 has been created to process this Pull Request

@engcom-Delta
Copy link
Contributor

✔️ QA passed

@m2-assistant
Copy link

m2-assistant bot commented Feb 7, 2020

Hi @krzksz, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@sdzhepa sdzhepa mentioned this pull request May 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants