Skip to content

Commit

Permalink
πŸ–πŸš€ Alternate position: fixed/absolute when docking/undocking (#32243)
Browse files Browse the repository at this point in the history
- πŸ–   Previously the video element would lag behind when using `position: fixed` at undock. `position: absolute` follows the video as it scrolls, eliminating the lag.  (This was backported from Bento version.)

- πŸš€  Use existing `clientRect` where possible to prevent `getBoundingClientRect()` calls.

- πŸš€  Migrates to `IntersectionObserver`.

Before / after (at 0.75 speed)
https://user-images.githubusercontent.com/254946/106031359-0756a300-6084-11eb-8bab-7cbe1f769313.mp4
  • Loading branch information
alanorozco committed Jan 28, 2021
1 parent fd1571d commit 6653828
Show file tree
Hide file tree
Showing 6 changed files with 268 additions and 206 deletions.
4 changes: 0 additions & 4 deletions build-system/test-configs/dep-check-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,10 +361,6 @@ exports.rules = [
'src/service/position-observer/position-observer-impl.js',
'extensions/amp-fx-collection/0.1/providers/fx-provider.js->' +
'src/service/position-observer/position-observer-worker.js',
'extensions/amp-video-docking/0.1/amp-video-docking.js->' +
'src/service/position-observer/position-observer-impl.js',
'extensions/amp-video-docking/0.1/amp-video-docking.js->' +
'src/service/position-observer/position-observer-worker.js',
'extensions/amp-analytics/0.1/cookie-writer.js->' +
'src/service/cid-impl.js',
'extensions/amp-next-page/0.1/next-page-service.js->' +
Expand Down
4 changes: 4 additions & 0 deletions extensions/amp-video-docking/0.1/amp-video-docking.css
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@

.amp-video-docked-shadow {
box-shadow: 0px 0 20px 6px rgba(0, 0, 0, 0.2);
transition-property: transform, opacity !important;
}

.amp-video-docked-controls-bg {
Expand Down Expand Up @@ -194,6 +195,9 @@
transform-origin: left top !important;

will-change: width, height, transition, transform, opacity;

/* Needs an arbitrary transition by default so browser won't glitch/jump. */
transition: 0.05s transform;
}

.i-amphtml-video-docked-overlay {
Expand Down

0 comments on commit 6653828

Please sign in to comment.