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 class="content">
  <section class="mt-5 mb-5 h-50-vh">
    <div class="container-fluid d-flex h-100 justify-content-center">
      <div class="row">
        <div class="col-12 d-flex h-100 justify-content-center flex-column">
          <h1 class="text-center">Title Animation!!</h1>
          <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur ratione laborum quis cum culpa, alias aut sequi! Dolor, praesentium totam dicta minus fugiat pariatur quia consequuntur sapiente illum repellat perferendis aliquid, iure, blanditiis laborum at necessitatibus sequi sint? Blanditiis, unde molestiae culpa soluta ullam ratione quis? A, sapiente eveniet soluta tempora ex sunt aperiam libero debitis corrupti porro asperiores esse dolore sed doloremque? Nostrum tempore nisi obcaecati alias facere culpa cum beatae deserunt eos, laborum sit provident qui esse unde illum doloribus odio dolore rem, totam, aliquam reiciendis magnam pariatur? Eligendi nulla distinctio debitis libero ex vero, nam iste soluta.</p>
        </div>
      </div>
    </div>
  </section>
  <section class="hov_bild">
    <div class="container-fluid red_ar">
      <img class="swipeimage" src="https://picsum.photos/id/239/200/200">

      <div class="text">
        <h1>text</h1>
      </div>

    </div>

    <div class="container-fluid red_ar">
      <img class="swipeimage" src="https://picsum.photos/id/237/200/200">

      <div class="text">
        <h1>text</h1>
      </div>

    </div>
  </section>
  <section class="mt-5 mb-5 h-50-vh">
    <div class="container-fluid d-flex h-100 justify-content-center">
      <div class="row">
        <div class="col-12 d-flex h-100 justify-content-center flex-column">
          <h2 class="text-center">Title Animation!!</h2>
          <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur ratione laborum quis cum culpa, alias aut sequi! Dolor, praesentium totam dicta minus fugiat pariatur quia consequuntur sapiente illum repellat perferendis aliquid, iure, blanditiis laborum at necessitatibus sequi sint? Blanditiis, unde molestiae culpa soluta ullam ratione quis? A, sapiente eveniet soluta tempora ex sunt aperiam libero debitis corrupti porro asperiores esse dolore sed doloremque? Nostrum tempore nisi obcaecati alias facere culpa cum beatae deserunt eos, laborum sit provident qui esse unde illum doloribus odio dolore rem, totam, aliquam reiciendis magnam pariatur? Eligendi nulla distinctio debitis libero ex vero, nam iste soluta.</p>
        </div>
      </div>
    </div>
  </section>
</div>

<div class="ball"></div>
              
            
!

CSS

              
                h1 {
  font-size: clamp(2rem, 1.5385rem + 2.0513vw, 4rem);
}

.ball {
  width: 50px;
  height: 50px;
  position: fixed;
  top: 0;
  left: 0;
  border: 3px solid dodgerblue;
  border-radius: 50%;
  pointer-events: none;
}

.red_ar {
  display: inline-block;
  background: #ff0000;
  width: 100%;
  padding-top: 40px;
  padding-bottom: 40px;
}

.red_ar img.swipeimage {
  position: fixed;
  top: 0;
  left: 0;
  width: 200px;
  height: 200px;
  object-fit: cover;
  z-index: 9;
  opacity: 0;
  visibily: hidden;
  pointer-events: none;
}
.h-50-vh {
  height: 50vh;
}

              
            
!

JS

              
                console.clear();

gsap.registerPlugin(ScrollTrigger, ScrollSmoother, ScrollToPlugin);

const smoother = ScrollSmoother.create({
  content: ".content",
  smooth: 1,
  normalizeScroll: true,
  // ignoreMobileResize: true,
  effects: true,
  preventDefault: true
});

gsap.set(".ball", { xPercent: -50, yPercent: -50 });

let xTo = gsap.quickTo(".ball", "x", { duration: 0.6, ease: "power3" }),
  yTo = gsap.quickTo(".ball", "y", { duration: 0.6, ease: "power3" });

window.addEventListener("mousemove", (e) => {
  xTo(e.clientX);
  yTo(e.clientY);
});

gsap.set(".red_ar img.swipeimage", { yPercent: -50, xPercent: -50 });

gsap.utils.toArray(".red_ar").forEach((el) => {
  const image = el.querySelector("img.swipeimage"),
    setX = gsap.quickSetter(image, "x", "px"),
    setY = gsap.quickSetter(image, "y", "px"),
    align = (e) => {
      setX(e.pageX);
      setY(e.pageY);
    },
    startFollow = () => document.addEventListener("mousemove", align),
    stopFollow = () => document.removeEventListener("mousemove", align),
    fade = gsap.to(image, {
      autoAlpha: 1,
      ease: "none",
      paused: true,
      onReverseComplete: stopFollow
    });

  el.addEventListener("mouseenter", (e) => {
    fade.play();
    startFollow();
    align(e);
  });

  el.addEventListener("mouseleave", () => fade.reverse());
});

              
            
!
999px

Console