Video Control

Animate playback of background videos with native Webflow interactions.

Built for Webflow

Snippet

Copy the <script> and paste it in the <head> tag or before </body>

<!-- Snippets by The Lazy God • Video Control -->
<script defer src="https://cdn.jsdelivr.net/gh/the-lazy-god/[email protected]/tlg-video-control.min.js"></script>

Setup

Required setup

  1. Add the attribute to the videos
  2. Create CSS variables for each unique video control
  3. Create your native Webflow interaction

1: Add the attribute to background video elements

Any background video element you want to control needs the attribute below added. You can use the the number as an identifier when using multiple videos on the same page.

Note: Make sure the videos are not set to autoplay.

Attribute
Name
tlg-video-control
Copy
Value
video-1
And video-2, video-3 and so on...
Copy

2: Create a variable for each video

Create a variable of type size for each video. This will be used to control the progress of the video.

Variable (type = size)
Name
tlg/video-control-1
Repeat for each video-2, video-3 and so on...
Copy
Value
0px
Initialize this value to 0px

3: Create native Webflow interactions

Create any Webflow interaction where you animate the variables you created above. The value of the variable going from 0 to 100 will correspond to video progress going from 0 to 100% completion.

Optional add-ons

  • Set maximum frames per second for each video

Set frames per second for each background video

Add this to the background video elements to set the maximum fps for the playback of that video. This doesn’t affect playback speed.

Default is 30 FPS.

Note: 30 fps seems to be the sweet spot for performance. Setting fps higher than 30 can result in choppy playback in Chrome.

Attribute
Optional
Name
tlg-video-scroll-fps
Copy
Value
{number}
Default: 30