Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <section style="height:50vh"></section>
<figure>
  <video src="https://easy-step.it/wp-content/uploads/2023/07/PUMA_FUTURE_ULTIMATE__Supercharge_Pack_23-vimeo-792287249-dash-fastly_skyfire_sep-video-5b63a452.mp4" playsinline="true" webkit-playsinline="true" preload="auto" muted="muted" class="video-background"></video>
</figure>
<section style="height:500vh"></section>
              
            
!

CSS

              
                @import url("https://fonts.googleapis.com/css?family=Signika+Negative:300,400&display=swap");

body {
  font-family: "Signika Negative", sans-serif;
  font-weight: 300;
  margin: 0;
  padding: 0 20px;
}

.video-background {
  min-width: 100%;
  min-height: 100%;
}


figure{
  clip-path: inset(0% 0%, 100% 0%, 100% 100%, 0% 100%);

}
              
            
!

JS

              
                console.clear(); // Start with a clean console on refesh 
ScrollTrigger.defaults({
  markers: true
});
const tl = gsap.timeline({
  // scrollTrigger: {
  //   id: "clippath",
  //   trigger: ".video-background",
  //   start: "top top",
  //   end: "*=100%",
  //   scrub: true
  // }
});
tl.to("figure", {
  duration: 2,
  // clipPath: "inset(0px 294.913px 141.157px 409.571px)"
  clipPath: "inset(34% 0%, 54% 0%, 53% 99%, 34% 100%)"
"
});
tl.from("figure",{ 
    duration: 2, 
  // clipPath: "inset(0px 0px 0px 0px)" 
  clipPath: "inset(25% 22%, 92% 28%, 63% 64%, 17% 76%)"

});

let videoScroll = document.querySelector(".video-background"),
  frameNumber = 0,
  src = videoScroll.currentSrc || videoScroll.src;

videoScrollTL = gsap.timeline({
  defaults: { duration: 1 },
  scrollTrigger: {
    id: "video",
    trigger: ".video-background",
    pin: true,
    scale: 1,
    start: "top top",
    end: "+=3000",
    scrub: true,
    markers: true,
    onUpdate: (self) => {
      frameNumber = (self.progress / 10) * 100 - 1; //this takes fine tuning divide your videos FPS by two. My video's FPS was 30, 14 was the sweet spot. -1 fixes an issue on safari where the video disappears at the end of the scrollTrigger
      videoScroll.currentTime = frameNumber;
    }
  }
});

/* Make sure the video is 'activated' on iOS */
function once(el, event, fn, opts) {
  var onceFn = function (e) {
    el.removeEventListener(event, onceFn);
    fn.apply(this, arguments);
  };
  el.addEventListener(event, onceFn, opts);
  return onceFn;
}

once(document.documentElement, "touchstart", function (e) {
  videoScroll.play();
  videoScroll.pause();
});

//make sure video has loaded
once(videoScroll, "loadedmetadata", function () {
  videoScrollTL.fromTo(
    videoScroll,
    { currentTime: 0 },
    { currentTime: videoScroll.duration - 0.1 }
  );
});

//When first coded, the Blobbing was important to ensure the browser wasn't dropping previously played segments, but it doesn't seem to be a problem now. Possibly based on memory availability?
setTimeout(function () {
  if (window["fetch"]) {
    fetch(src)
      .then(function (response) {
        return response.blob();
      })
      .then(function (response) {
        var blobURL = URL.createObjectURL(response);
        var t = videoScroll.currentTime;
        once(document.documentElement, "touchstart", function (e) {
          videoScroll.setAttribute("src", blobURL);
          videoScroll.currentTime = t + 0.01;
        });
      });
  }
}, 0);

              
            
!
999px

Console