Jump to content
Search Community

video and section text animation on scroll

adamchampagne test
Moderator Tag

Recommended Posts

We are trying to create a section that have multiple content, each content is 100% view height. That section will have a video in background.
Whenever user scroll down, new content will fade in and video will play a part of it.

For example, 3 contents and a video with 9s, each content will play 3 seconds of video then pause when user scroll up or down.
Please recommend a platform to embed code because we can not login to codepen.io.

Link to comment
Share on other sites

 It sounds like your are looking for the Observer plugin https://gsap.com/docs/v3/Plugins/Observer/

 

See the Pen XWzRraJ by GreenSock (@GreenSock) on CodePen

 

And below our Stackblitz starter templates if Codepen isn't working for you. 

 

CodePen isn't always ideal for these tools, so here are some Stackblitz starter templates that you can fork and import the gsap-trial NPM package for using any of the bonus plugins: 

 

Please share the StackBlitz link directly to the file in question (where you've put the GSAP code) so we don't need to hunt through all the files. 

 

Once we see an isolated demo, we'll do our best to jump in and help with your GSAP-specific questions. 

Link to comment
Share on other sites

Thanks, but Observer isn't what we're looking for. We want the video background to stay the same.

The idea is:

- You have 3 steps,

- The section will be placed under a video background

- When you come to the section, step 1 will show, video plays from 0.0 to 0.4 then stop

- You scroll again, step 2 will show, video continue play from 0.4 to 0.8,

- You scroll 1 more time, step 3 will show, video continue play from 0.8 to end.

 

 

step-2.png

step-1.png

Link to comment
Share on other sites

I still think it is, but that doesn't matter much. If you can provide a minimal demo with what you've already tried we'll be happy to take a look and point you in the right direction. 

 

The Observer plugin allows you to watch for scroll events and then do logic based on that. So you'll only need some javascript that plays a video to a current time stamp and then watch for a scroll event again and do it all over again. 

Link to comment
Share on other sites

2 hours ago, adamchampagne said:

We do not know how to controll to play video by using gsap.

I think you don't, GSAP is for animating something and a video is already an animation on it self, but Javascript can. Here an example that scrolls to 4 8 and 10 seconds of the video after searching for you exact question I found that you can put an addEventListener on a video and watch for timeupdate and then do some logic based on that. I've hooked it to the Observer plugin to watch for scroll events and then run some function. Hope it helps and happy tweening! 

 

See the Pen KKYMdRo?editors=0010 by mvaneijgen (@mvaneijgen) on CodePen

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...