Jump to content
Search Community

how to play a video when page is triggered screen

kanishk soni test
Moderator Tag

Recommended Posts

something like this? this is probably not correct code but it works for me to trigger a video element when it comes into view.
you can actually also achieve this with playsInline and autoPlay maybe?


useGSAP(() => {
gsap.to(segments[0].videoRef.current, { // ref attached to your videoelement
scrollTrigger: {
trigger: segments[0].videoRef.current, // when the videoelement comes into viewport
start: "top bottom",
onEnter: () => segment0.current?.play(),
},
})
}, [])
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...