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

              
                <div id="target">
  <img src="https://uploads-ssl.webflow.com/6279603fc06c70d8ee750f47/6279603fc06c7056d1750f72_main_brady_grey.jpg" />
</div>
<section>
	<h1>SECTION 1</h1>
</section>
<section>
	<h1>SECTION 2</h1>
</section>
<section>
	<h1>SECTION 3</h1>
</section>
<section>
	<h1>SECTION 4</h1>
</section>
<section>
	<h1>SECTION 5</h1>
</section>
<section>
	<h1>SECTION 6</h1>
</section>
<section>
	<h1>SECTION 7</h1>
</section>
<section>
	<h1>SECTION 8</h1>
</section>
              
            
!

CSS

              
                body{
  margin:0;
  width:100%;
  background-color:grey;
  font-family:sans-serif;
  text-align:center;
  overscroll-behavior: none;
}
section{
  position:relative;
  height:100vh;
  border-bottom:1px solid #636363;
  width: 15%;
}
#short{
  position: relative;
  height: 5vh;
  border-bottom:1px solid #636363;
  width: 15%;
}
h1{
  position:absolute;
  top:50px;
  font-size:1.5em;
  line-height: 1;
  font-family:sans-serif;
  color: #fff;
  margin: 0 0 0 20px;
}
#target {
  position: fixed;
  right: 0;
  top: 0;
  background: #333;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}
#target img {
  height: 100%;
}
              
            
!

JS

              
                // This effect lets you zoom in on a particular spot on the target - you define the scale and the origin as an Array of x/y normalized values.
// Like {scale: 3, origin: [0.25, 0.8]} will zoom in on the spot that's 25% from the left, and 80% from the top of the element/image.
// It will return an animation that controls the xPercent, yPercent, and scale (as well as any other values you pass in, like a normal tween)
// It won't let the edges collapse toward the center. It's best to put the element into a container that has overflow: hidden.
gsap.registerEffect({
  name: "zoom",
  effect: (targets, config) => {
    const vars = {transformOrigin: "0px 0px", ...config},
          { scale, origin } = config,
          clamp = gsap.utils.clamp(-100 * (scale - 1), 0);
    delete vars.origin;
    vars.xPercent = clamp((0.5 - origin[0] * scale) * 100);
    vars.yPercent = clamp((0.5 - origin[1] * scale) * 100);
    vars.overwrite = "auto";
    return gsap.to(targets, vars);
  },
  extendTimeline: true,
  defaults: {origin: [0.5, 0.5], scale: 2}
});

// for each section, we define the zoom data here
const zoomData = [
  {scale: 1, origin: [0.5, 0.5]},
  {scale: 3, origin: [0.75, 1]},
  {scale: 2, origin: [0.5, 0.5]},
  {scale: 3, origin: [0.25, 0]},
  {scale: 2, origin: [0.5, 0.5]},
  {scale: 3, origin: [0.25, 1]},
  {scale: 2, origin: [0.5, 0.5]},
  {scale: 3, origin: [0.25, 0.3]}
];
  // now create the timeline that we'll scrub
  tl = gsap.timeline({
    scrollTrigger: {
      start: 0, // start from the top
      end: "+=" + ((zoomData.length - 1) * 100) + "%", // each section is 100% of the viewport height
      scrub: 0.5 // take 0.5 to catch up to scroll position
    }
  });

        // set the starting state
gsap.effects.zoom("#target", {scale: zoomData[0].scale, origin: zoomData[0].origin, duration: 0});

// now loop through subsequent sections and create the ScrollTrigger accordingly.
zoomData.slice(1).forEach(data => {
  tl.zoom("#target img", {
    scale: data.scale,
    origin: data.origin,
    ease: "power1.inOut"
  });
});
              
            
!
999px

Console