Skip to content

fix(img): correctly determine when to load image when scrolling quickly on slower devices #23704

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

Merged
merged 4 commits into from
Aug 9, 2021

Conversation

Jacob-McKay
Copy link
Contributor

@Jacob-McKay Jacob-McKay commented Jul 30, 2021

Fix for this issue: #23703

There is a rare race condition you may experience on devices with slower CPU where the Intersection Observer API supplies multiple items to the callback, instead of only a single element which the previous code assumed it would get. This changes takes the last item (which will be the most current information).

Pull request checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)
  • Build (npm run build) was run locally and any changes were pushed
  • Lint (npm run lint) has passed locally and any fixes were made for failures

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

Issue Number: 23703

What is the new behavior?

  • Instead of keying off of the first item in the callback to the ion-img Intersection Observer API callback, take the last, most recent one to determine whether the img is on screen and should load

Does this introduce a breaking change?

  • Yes
  • No

Other information

Sorry, something went wrong.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
There is a rare race condition you may experience on devices with slower CPU where the Intersection Observer API supplies multiple items to the callback, instead of only a single element which the previous code assumed it would get.  This changes takes the last item (which will be the most current information).
@github-actions github-actions bot added the package: core @ionic/core package label Jul 30, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@liamdebeasi liamdebeasi changed the title [Fix] Use last item in the Intersection API callback fix(img): correctly determine when to load image when scrolling quickly on slower devices Aug 2, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Copy link
Contributor

@liamdebeasi liamdebeasi left a comment

Choose a reason for hiding this comment

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

Thank you! This is good to merge when the tests pass.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@Jacob-McKay Jacob-McKay closed this Aug 3, 2021
@Jacob-McKay
Copy link
Contributor Author

Ope, thought I that was a 'complete' button

@Jacob-McKay Jacob-McKay reopened this Aug 3, 2021
@willmartian willmartian self-requested a review August 3, 2021 04:43
@liamdebeasi liamdebeasi merged commit 067e621 into ionic-team:main Aug 9, 2021
@liamdebeasi
Copy link
Contributor

Merged. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: core @ionic/core package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants