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

Infinite Scroll: Prevent DOM Caching when Switching to/from Fullscreen #10101

Merged
merged 1 commit into from
Sep 14, 2018

Conversation

mdawaffe
Copy link
Member

@mdawaffe mdawaffe commented Sep 5, 2018

Changes proposed in this Pull Request:

When scrolling, Infinite Scroll periodically looks to see what DOM
elements are no longer in the viewport, caches them, and removes them from
the DOM.

On Android (and others?), switching to/from fullscreen triggers the
scroll event, which, in turn, triggers this DOM manipulation. The switch
to fullscreen mode also confuses Infinite Scroll's understanding of what
is visible in the viewport.

Playing a VideoPress video (or fullscreening a Vimeo or other video) on
Android can therefore remove the video from the DOM, which obviously
breaks everything :)

This patch uses the Fullscreen API
to determine if the browser has switched to or from fullscreen in between
throttled scroll events. If it has, Infinite Scroll will not do any of its
DOM manipulation. (Any manipulation required will get picked up if the
viewer continues to scroll.)

Reported: p1535429757000200-slack-CBG1CP4EN

Differential Revision: D17671-code

This commit syncs r180311-wpcom.

Testing instructions:

Test Plan:

  1. On a test site, have enough posts for Infinite Scroll.
  2. On a post sufficiently early (at least one Infinite Scroll "page"
    down), add a VideoPress video, e.g. [wpvideo MnTIDupg]
  3. On Android, open the site, and scroll down until the VideoPress post is
    visible.
  4. Click the video to begin play.

Prior to this patch: see the video start to play, then immediately
disappear.

After this patch: see the video play.

Also:

  • Make sure things look normal elsewhere, both mobile and desktop.

Proposed changelog entry for your changes:

Fix video playback of VideoPress videos loaded via Infinite Scroll.

Summary:
When scrolling, Infinite Scroll periodically looks to see what DOM
elements are no longer in the viewport, caches them, and removes them from
the DOM.

On Android (and others?), switching to/from fullscreen triggers the
`scroll` event, which, in turn, triggers this DOM manipulation. The switch
to fullscreen mode also confuses Infinite Scroll's understanding of what
is visible in the viewport.

Playing a VideoPress video (or fullscreening a Vimeo or other video) on
Android can therefore remove the video from the DOM, which obviously
breaks everything :)

This patch uses the [Fullscreen API](https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API)
to determine if the browser has switched to or from fullscreen in between
throttled scroll events. If it has, Infinite Scroll will not do any of its
DOM manipulation. (Any manipulation required will get picked up if the
viewer continues to scroll.)

Reported: p1535429757000200-slack-CBG1CP4EN

Test Plan:
1. On a test site, have enough posts for Infinite Scroll.
2. On a post sufficiently early (at least one Infinite Scroll "page"
   down), add a VideoPress video, e.g. `[wpvideo MnTIDupg]`
3. On Android, open the site, and scroll down until the VideoPress post is
   visible.
4. Click the video to begin play.

Prior to this patch: see the video start to play, then immediately
disappear.

After this patch: see the video play.

Also:
* Make sure things look normal elsewhere, both mobile and desktop.

Reviewers: blowery, zinigor

Tags: #touches_jetpack_files

Differential Revision: D17671-code

This commit syncs r180311-wpcom.
@mdawaffe mdawaffe added [Type] Bug When a feature is broken and / or not performing as intended [Feature] Infinite Scroll [Feature] VideoPress A feature to help you upload and insert videos on your site. [Status] Needs Review This PR is ready for review. labels Sep 5, 2018
@mdawaffe mdawaffe added this to the 6.6 milestone Sep 5, 2018
@mdawaffe mdawaffe self-assigned this Sep 5, 2018
@mdawaffe mdawaffe requested a review from a team as a code owner September 5, 2018 19:58
@jetpackbot
Copy link
Collaborator

That's a great PR description, thank you so much for your effort!

Generated by 🚫 dangerJS

Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

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

I could only test on Android and on desktop, but it seems to work well there! 🚢

@jeherve jeherve added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review This PR is ready for review. labels Sep 11, 2018
@mdawaffe mdawaffe merged commit 1a27bee into master Sep 14, 2018
@ghost ghost removed the [Status] Ready to Merge Go ahead, you can push that green button! label Sep 14, 2018
@mdawaffe mdawaffe deleted the sync/mdawaffe/r180311-wpcom-1536177273 branch September 14, 2018 20:41
jeherve added a commit that referenced this pull request Sep 24, 2018
jeherve added a commit that referenced this pull request Sep 25, 2018
* Readme: add boilerplate for next release, 6.6

* Add 6.5 to the changelog.txt file

* Set boilerplate testing list for 6.6

* Readme: update stable tag to 6.5

* Add bullets to 6.5 changelog items

* Readme: add link to previous changelogs

This will help folks who want to know more about past releases,
while keeping the readme.txt short so as to not overwhelm translators and site owners only looking for information about the last release.

* Changelog: add information at the top of the changelog file.

* Changelog: add #10054

* Changelog: add #10078

* Changelog: add #10079

* Changelog: add #10064

* Changelog: add #10094

* Changelog: add #10096

* Testing list: add more information based on #10087

* Changelog: add #9847

* Changelog: add #10084

* Changelog: add #9918

* Changelog: add #7614

* Changelog: add #10116

* Changelog: add #10108

* Changelog: add #10041

* Changelog: add #10121

* Changelog: add #10134

* Changelog: add #10130

* Changelog: add #10109

* changelog: add #10137

* changelog: add #9952

* changelog: add #10120

* changelog: add #10162

* Changelog: add #10163

* Changelog: add #10092

* changelog: add #10156

* Changelog: add #10154

* changelog: add #10122

* Changelog: add #10101

* changelog: add #10105

* changelog: add #10190

* Changelog: add #10196

* changelog: add #10152

* Changelog: add #10153

* Testing list: add more details to Site Verification testing steps.

@see #10143 (comment)

* changelog: add #10194

* Changelog: add #10193
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Infinite Scroll [Feature] VideoPress A feature to help you upload and insert videos on your site. Touches WP.com Files [Type] Bug When a feature is broken and / or not performing as intended [Type] Dotcom Merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants