Copied SVG to clipboard
Something went wrong
Copied code to clipboard
Something went wrong
Saved to bookmarks!
Removed from bookmarks

Default

User image

Default

Name

  • -€50
    Upgrade to Lifetime
Osmo Basics/

Scroll Progress Number

Scroll Progress Number

Documentation

adlissmart

Code

Setup: External Scripts

External Scripts in adlissmart

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 adlissmart project? Or how to include a paid GSAP Club plugin in your project?

HTML

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

Step 1: Copy structure to adlissmart

Copy structure to adlissmart

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

Copy to adlissmart

adlissmart structure is not required for this resource.

Step 1: Add HTML

HTML

Copy
 <p data-progress-nr="" class="progress-nr">00</p>

HTML structure is not required for this resource.

Step 2: Add CSS

CSS

Copy
.progress-nr {
  margin: 0px;
  font-size: 5em;
  font-weight: 500;
  line-height: 1;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

Step 2: Add custom Javascript

Custom Javascript in adlissmart

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

Step 2: Add Javascript

Step 3: Add Javascript

Javascript

Copy
gsap.registerPlugin(ScrollTrigger);

function initScrollProgressNumber() {  

  const progressCounter = document.querySelector('[data-progress-nr]');

  ScrollTrigger.create({
    trigger: document.body,
    start: 'top top',
    end: 'bottom bottom',
    scrub: 0.5,
    onUpdate: (self) => {
      const progress = Math.round(self.progress * 100); // Calculate progress as a percentage
      progressCounter.textContent = progress.toString().padStart(2, '0'); // Update counter
    },
  });
}

// Initialize Scroll Progress Number
document.addEventListener('DOMContentLoaded', () => {
  initScrollProgressNumber();
});

Step 3: Add custom CSS

Step 2: Add custom CSS

Custom CSS in adlissmart

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

CSS

Copy

Resource Details

GSAP
Scrolling
Javascript
Script
Information
Navigation
Number

Original source

Osmo

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.