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 class="section1">
    <div class="yellow-section">
      <div id="video-container">
        <video id="video" autoplay loop muted playsinline>
          <source src="https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/720/Big_Buck_Bunny_720_10s_1MB.mp4" type="video/mp4">
          Your browser does not support the video tag.
        </video>
      </div>

      <svg class="masker" viewBox="0 0 1920 1080" preserveAspectRatio="none">

        <defs>
          <clipPath id="heading_mask">
            <path id="tri1" d="M974.03,555h-28.06l14.01-30L974.03,555z"/>
          </clipPath>
        </defs>
      </svg>

      <div class="heading">
        
      </div>
    </div>

  </section>

              
            
!

CSS

              
                body {
overflow-x: hidden;
}

section {
  position:relative;
  width: 100vw;
  height: 100vh;
}

.yellow-section {
  position:absolute;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100vh;

  #video-container {
    position: absolute;
    inset: 0;
    overflow: hidden;
    z-index: -1;

    video {
      position: absolute;
      width: 100%;
      height: 100%;
      object-fit: cover;
    }
  }

  svg.masker {
    position: absolute;
    width: 1920px;
    height: 1080px;
    left: 50%;
    top: 50%;
    transform: translateX(-50%) translateY(-50%);
  }

  .heading {
    position: absolute;
    inset: 0;
    background-color: #ffe825;
    clip-path: url(#heading_mask);
  }
}
              
            
!

JS

              
                gsap.registerPlugin(ScrollTrigger);

function calculateXValue() {
  // Your logic here
  // For example, to calculate x as 50% of the viewport width:
  const viewportWidth = window.innerWidth;
  return (1920 - viewportWidth) * -0.5; // 50% of viewport width
}

function calculateYValue() {
  // Your logic here
  // For example, to calculate x as 50% of the viewport height:
  const viewportHeight = window.innerHeight;
  return (1080 - viewportHeight) * -0.5; // 50% of viewport height
}

// Wait for the document to be ready
document.addEventListener("DOMContentLoaded", function () {
  
  let triangle1 = document.getElementById("tri1");
	let timeline1 = gsap.timeline({
		scrollTrigger: {
			id: "tri1",
			trigger: ".yellow-section",
			start: "bottom 100%",
			end: "bottom -100%",
			scrub: true,
			markers: true,
			pin: true,
			invalidateOnRefresh: true
		},
	});

	// Set the initial values
	gsap.set(triangle1, {
		x: calculateXValue(),
		y: calculateYValue(),
		scale: 0,
		transformOrigin: "center center",
		ease: "none",
	});


	// Add animation steps to the timeline

	timeline1
	.to(triangle1, {
		x: calculateXValue(),
		y: calculateYValue(),
		scale: 3, // Scale up the triangle
		duration: 0.1,
	})
	.to(triangle1, {
		x: calculateXValue(),
		y: calculateYValue(),
		scale: 150, // Scale up the triangle
		rotation: 90, // Rotate the triangle by 360 degrees
		duration: 0.5,
	});
});
              
            
!
999px

Console