Copied SVG to clipboard
Something went wrong
Copied code to clipboard
Something went wrong
Saved to bookmarks!
Removed from bookmarks
Webflow Challenge: Win $5K

Default

User image

Default

Name

  • -€50
    Upgrade to Lifetime
The Vault/

Accelerating Globe on Scroll

Accelerating Globe on Scroll

Documentation

Webflow

Code

Setup: External Scripts

External Scripts in Webflow

Make sure to always put the External Scripts before the Javascript step of the resource.

In this video you learn where to put these in your Webflow project? Or how to include a paid GSAP Club plugin in your project?

HTML

Copy
<script src="https://cdn.jsdelivr.net/npm/gsap@3.13.0/dist/gsap.min.js"></script>

Step 1: Copy structure to Webflow

Copy structure to Webflow

In the video below we described how you can copy + paste the structure of this resource to your Webflow project.

Copy to Webflow

Webflow structure is not required for this resource.

Step 1: Add HTML

HTML

Copy
<div data-accelerating-globe="" class="globe">
  <div class="globe__before"></div>
  <div class="globe__back">
    <div class="globe__back-circle"></div>
    <div class="globe__back-circle is--1"></div>
    <div class="globe__back-circle is--2"></div>
    <div class="globe__back-circle is--3"></div>
    <div class="globe__back-circle is--4"></div>
    <div class="globe__back-circle is--5"></div>
  </div>
  <div class="globe__front">
    <div class="globe__mirror">
      <div data-accelerating-globe-circle="" class="globe__circle">
        <div class="globe__circle-inner"></div>
      </div>
      <div data-accelerating-globe-circle="" class="globe__circle">
        <div class="globe__circle-inner"></div>
      </div>
      <div data-accelerating-globe-circle="" class="globe__circle">
        <div class="globe__circle-inner"></div>
      </div>
      <div data-accelerating-globe-circle="" class="globe__circle">
        <div class="globe__circle-inner"></div>
      </div>
    </div>
    <div class="globe__mirror is--duplicate">
      <div data-accelerating-globe-circle="" class="globe__circle">
        <div class="globe__circle-inner"></div>
      </div>
      <div data-accelerating-globe-circle="" class="globe__circle">
        <div class="globe__circle-inner"></div>
      </div>
      <div data-accelerating-globe-circle="" class="globe__circle">
        <div class="globe__circle-inner"></div>
      </div>
      <div data-accelerating-globe-circle="" class="globe__circle">
        <div class="globe__circle-inner"></div>
      </div>
    </div>
  </div>
</div>

HTML structure is not required for this resource.

Step 2: Add CSS

CSS

Copy
.globe {
  color: #d500ff;
  justify-content: center;
  align-items: center;
  width: 37.5vw;
  display: flex;
  position: relative;
}

.globe__before {
  padding-top: 100%;
}

.globe__back {
  border-radius: 50%;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  display: flex;
  position: absolute;
  overflow: hidden;
}

.globe__back-circle {
  border: 1px solid;
  border-radius: 50%;
  width: 100%;
  height: 100%;
  position: absolute;
}

.globe__back-circle.is--1 {
  width: 50%;
  height: 16%;
  top: 0%;
}

.globe__back-circle.is--2 {
  width: 87.5%;
  height: 24%;
  top: 14%;
}

.globe__back-circle.is--3 {
  border-radius: 50%;
  width: 100%;
  height: 28%;
  top: 36%;
}

.globe__back-circle.is--4 {
  width: 87.5%;
  height: 24%;
  top: 62%;
}

.globe__back-circle.is--5 {
  width: 50%;
  height: 16%;
  top: 84%;
}

.globe__front, .globe__mirror {
  width: 100%;
  height: 100%;
  position: absolute;
}

.globe__mirror.is--duplicate {
  transform: scaleX(-1);
}

.globe__circle {
  width: 50%;
  height: 100%;
  position: absolute;
  left: auto;
  right: 50%;
  overflow: hidden;
}

.globe__circle-inner {
  border: 1px solid;
  border-radius: 50%;
  width: 200%;
  height: 100%;
  position: absolute;
}

Step 2: Add custom Javascript

Custom Javascript in Webflow

In this video, Ilja gives you some guidance about using JavaScript in Webflow:

Step 2: Add Javascript

Step 3: Add Javascript

Javascript

Copy
function initAcceleratingGlobe() {
  document.querySelectorAll('[data-accelerating-globe]').forEach(function(globe) {
    const circles = globe.querySelectorAll('[data-accelerating-globe-circle]');
    if (circles.length < 8) return; // Min 8

    const tl = gsap.timeline({
      repeat: -1,
      defaults: { duration: 1, ease: "none" }
    });

    const widths = [
      ["50%", "37.5%"],
      ["37.5%", "25%"],
      ["25%", "12.5%"],
      ["calc(12.5% + 1px)", "calc(0% + 1px)"],
      ["calc(0% + 1px)", "calc(12.5% + 1px)"],
      ["12.5%", "25%"],
      ["25%", "37.5%"],
      ["37.5%", "50%"]
    ];

    circles.forEach((el, i) => {
      const [fromW, toW] = widths[i];
      tl.fromTo(el, { width: fromW }, { width: toW }, i === 0 ? 0 : "<");
    });

    let lastY = window.scrollY;
    let lastT = performance.now();
    let stopTimeout;

    function onScroll() {
      const now = performance.now();
      const dy = window.scrollY - lastY;
      const dt = now - lastT;
      lastY = window.scrollY;
      lastT = now;

      const velocity = dt > 0 ? (dy / dt) * 1000 : 0; // px/s
      const boost = Math.abs(velocity * 0.005);
      const targetScale = boost + 1;

      tl.timeScale(targetScale);

      clearTimeout(stopTimeout);
      stopTimeout = setTimeout(() => {
        gsap.to(tl, {
          timeScale: 1,
          duration: 0.6,
          ease: "power2.out",
          overwrite: true
        });
      }, 100);
    }

    window.addEventListener("scroll", onScroll, { passive: true });
  });
}

// Initialize Accelerating Globe on Scroll
document.addEventListener('DOMContentLoaded', function() {
  initAcceleratingGlobe();
});

Step 3: Add custom CSS

Step 2: Add custom CSS

Custom CSS in Webflow

Curious about where to put custom CSS in Webflow? Ilja explains it in the below video:

CSS

Copy

Implementation

Globe

Use [data-accelerating-globe] to initialize the globe instance and scope all child selectors to this element.

Circle

Use [data-accelerating-globe-circle] on each front ring to enter the mirrored animation. Min of 4 per side.

Resource Details

Scrolling
Accelerating
Globe
Animation
Autoplay
Rotate
Rotate

Original source

Dennis Snellenberg

Creator Credits

We always strive to credit creators as accurately as possible. While similar concepts might appear online, we aim to provide proper and respectful attribution.