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

✨ Implement video docking (minimize to corner) #14961

Merged
merged 45 commits into from
May 10, 2018

Conversation

alanorozco
Copy link
Member

@alanorozco alanorozco commented Apr 30, 2018

Partial for #14061

Passed over some ideas/corner cases from original implementation (#14614, thanks @wassgha!), but defers to runtime APIs when possible and keeps less state for sanity/robustness.

Features

  • Calculates margin/size based on viewport.
  • Interpolates transition
  • Times out transition
  • Creates build rule for CSS as not to bloat the core binary.
  • Snap to corner
  • Flick to dismiss

Demo

http://slicing-cheese.glitch.me

In follow-up PRs:

(in no particular order)

  • Animate flick to dismiss using flick vector.
  • Don't show controls after dragging. (Done already.)
  • Refresh on resize. (Done already.)
  • Dock to container.
  • Tests for controls and snap to corner.
  • Video should not switch positions when scrolling quickly past the component container. (Fixed.)
  • Integration tests.

const refs = map();

if (root.hasAttribute('ref')) {
Copy link
Member Author

Choose a reason for hiding this comment

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

@jridgewell Added this as a convenience. The alternative would be to modify the result of htmlRefs when root + refs are meant to be referenced in the same object.

Copy link
Contributor

Choose a reason for hiding this comment

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

You already have a reference to root, because you passed it in.

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, nvm. I'm noticing that it was designed specifically not to set refs on root.

@alanorozco alanorozco requested a review from aghassemi April 30, 2018 15:56
@wassgha
Copy link
Contributor

wassgha commented Apr 30, 2018

Love it! Will review when out of WIP! Thanks :)

Copy link
Contributor

@jridgewell jridgewell left a comment

Choose a reason for hiding this comment

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

Lol, forgot to submit the review.

const refs = map();

if (root.hasAttribute('ref')) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You already have a reference to root, because you passed it in.

@alanorozco
Copy link
Member Author

@jridgewell Yup, I had added that only as a convenience. Either way, removed.

@wassgha
Copy link
Contributor

wassgha commented May 2, 2018

I think dragging shouldn't be enabled until the video is fully ducked because it causes some wired behavior if the user snaps the video to a different corner as it is docking.

@alanorozco
Copy link
Member Author

@wassgha Fixed. The demo is a little out of date.

@theodab
Copy link

theodab commented May 3, 2018

I was playing around with the demo page some. I found that if I selected the cheese slicing video and then scrolled back and forth rapidly with home and end, sometimes the video would move to the bottom-right corner on its own. I assume that's a bug?

I was testing with Chrome 66 on a Mac, if it's relevant.

@alanorozco
Copy link
Member Author

@aghassemi PTAL

transitionDurationMs > 200 ? 'ease-in' : 'linear';

const positioningStyles = {
'width': px(width),
Copy link
Contributor

Choose a reason for hiding this comment

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

do we still need to set width/height given scale is being set now? would be nice to avoid if at all possible since it is causes relayout (although just relayout of video box) if not avoidable, let's add "will-change: width, height, transform" to the CSS of the docking container.

Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately yes, because we need to set the aspect ratio for each sized element.

Made a small optimization to set/reset dimensions only for first and last frames and added will-change.


attribute: **`dock`**

**Experimental feature. Setting this attribute is not currently valid.**
Copy link
Contributor

Choose a reason for hiding this comment

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

so I assume the strategy is no experimental flag and using validation rules to keep this experimental until ready? (if so, thumbs up from me)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup!

@alanorozco alanorozco merged commit f7bb404 into ampproject:master May 10, 2018
@wassgha
Copy link
Contributor

wassgha commented May 10, 2018

Is the demo page up to date?

@alanorozco
Copy link
Member Author

@wassgha This demo should work. The video must be manually playing.

@wassgha
Copy link
Contributor

wassgha commented May 10, 2018

It does work but I am seeing two glitches, one that has to do with the chrome navigation bar showing/hiding on scroll. I remember working on this and not sure if there was a solution to it. The second bug is related to snapping (the video sometimes snaps to the middle of the screen or to the sides)
ezgif com-gif-maker

@dreamofabear
Copy link

Looks like this knocked 0.5KB off of v0.js. Nice! /cc @jridgewell

@alanorozco
Copy link
Member Author

@wassgha Thanks for catching those. Filed #15402 and #15403

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants