Jump to content
Search Community

Video play with scrub doesn't work in the middle of other content

LSchneiderman test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

I've seen lovely videos playing with scrub when the video is the only thing on the page, like this:

See the Pen ExZGrbZ by wisearts (@wisearts) on CodePen

 

But when the video is surrounded by other content on a page -- as it will inevitably be -- how do you get the video play on scrub AND hold off the  other content from scrolling over it until it's done playing?

See the Pen ZEqeJWx by lschneiderman (@lschneiderman) on CodePen

Link to comment
Share on other sites

  • Solution

That's just a CSS issue - you were pinning the <video> element itself which you set to position: absolute INSIDE of a container <div> that's affecting layout. So when ScrollTrigger added a bunch of pinSpacing to the bottom of the <video>, it made no difference in the layout. You need to pin the container element so that the pinSpacing actually pushes other stuff down the page: 

See the Pen PoypQxd?editors=0010 by GreenSock (@GreenSock) on CodePen

 

I also corrected and simplified some of the code. You should only listen for the metadataloaded or dataloaded events if it's not already loaded (it might be cached in which case it'd skip that code completely). 

 

I hope that helps. 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...