Convert Figma logo to code with AI

jlmakes logoscrollreveal

Animate elements as they scroll into view.

22,330
2,255
22,330
41

Top Related Projects

26,486

Animate on scroll library

9,901

Reveal CSS animation as you scroll down a page

10,405

Simple & lightweight (<4kb gzipped) vanilla JavaScript library to create smooth & beautiful animations when you scroll.

3,593

🚀 Performance focused, lightweight scroll animation library 🚀

🛤 Detection of elements in viewport & smooth scrolling with parallax.

Let your page react to scroll changes.

Quick Overview

ScrollReveal is a JavaScript library for easily animating elements as they enter/leave the viewport. It allows developers to create scroll-based reveal animations with minimal code, enhancing the visual appeal and user experience of web pages.

Pros

  • Easy to use with a simple API
  • Lightweight and performant
  • Customizable with various animation options
  • Works well across different devices and browsers

Cons

  • Limited to scroll-based animations only
  • May not be suitable for complex, multi-step animations
  • Requires JavaScript to function, which might not be ideal for all projects
  • Some advanced features require a commercial license

Code Examples

  1. Basic usage:
ScrollReveal().reveal('.element');

This code reveals an element with class 'element' using default animation settings.

  1. Custom animation:
ScrollReveal().reveal('.element', {
    delay: 200,
    distance: '50px',
    origin: 'bottom',
    duration: 1000
});

This example reveals an element with a 200ms delay, sliding up 50px from the bottom over 1 second.

  1. Sequence animation:
ScrollReveal().reveal('.element', { interval: 200 });

This code reveals multiple elements with the 'element' class in sequence, with a 200ms delay between each.

Getting Started

  1. Install ScrollReveal via npm:

    npm install scrollreveal
    
  2. Import and initialize ScrollReveal in your JavaScript file:

    import ScrollReveal from 'scrollreveal';
    
    const sr = ScrollReveal();
    
  3. Add reveal animations to your elements:

    sr.reveal('.my-element', {
        duration: 1000,
        origin: 'bottom',
        distance: '20px'
    });
    
  4. Ensure your HTML elements have the corresponding class:

    <div class="my-element">This will be revealed</div>
    

Competitor Comparisons

26,486

Animate on scroll library

Pros of AOS

  • Simpler setup and usage, with more straightforward configuration options
  • Supports a wider range of animation effects out of the box
  • Better documentation and examples for quick implementation

Cons of AOS

  • Less customizable and flexible compared to ScrollReveal
  • May have performance issues with a large number of animated elements
  • Limited control over animation timing and sequencing

Code Comparison

ScrollReveal:

ScrollReveal().reveal('.element', {
    delay: 200,
    distance: '50px',
    origin: 'bottom',
    easing: 'cubic-bezier(0.5, 0, 0, 1)'
});

AOS:

<div data-aos="fade-up" data-aos-delay="200" data-aos-easing="ease-in-out">
    Content
</div>

Both libraries aim to add scroll-based animations to web pages, but they differ in implementation and flexibility. ScrollReveal offers more granular control over animations through JavaScript, while AOS relies on HTML attributes for configuration. ScrollReveal is better suited for complex, custom animations, whereas AOS excels in simplicity and ease of use for common animation scenarios. The choice between the two depends on the project's specific requirements and the developer's preference for configuration style.

9,901

Reveal CSS animation as you scroll down a page

Pros of WOW

  • Simpler setup and usage, requiring less configuration
  • Lightweight with no dependencies, resulting in a smaller file size
  • Supports older browsers like IE9+

Cons of WOW

  • Less customizable compared to ScrollReveal
  • Limited animation options and effects
  • No longer actively maintained (last commit in 2015)

Code Comparison

WOW:

new WOW().init();

<div class="wow fadeInUp" data-wow-duration="2s"></div>

ScrollReveal:

ScrollReveal().reveal('.element', {
  duration: 2000,
  origin: 'bottom',
  distance: '50px'
});

Key Differences

  • ScrollReveal offers more advanced features and customization options
  • WOW relies on CSS classes for animations, while ScrollReveal uses JavaScript
  • ScrollReveal is actively maintained and updated, providing better support and bug fixes
  • WOW is more suitable for simple projects with basic animation needs
  • ScrollReveal provides better performance and smoother animations on modern browsers

Both libraries aim to add scroll-based animations to web pages, but ScrollReveal offers more flexibility and ongoing development. WOW may be preferable for projects requiring simplicity and broader browser support, while ScrollReveal is better suited for more complex animations and modern web applications.

10,405

Simple & lightweight (<4kb gzipped) vanilla JavaScript library to create smooth & beautiful animations when you scroll.

Pros of lax.js

  • More versatile with a wider range of animation effects
  • Supports complex, multi-step animations
  • Lightweight and easy to implement

Cons of lax.js

  • Less browser support compared to ScrollReveal
  • Steeper learning curve for advanced animations
  • Documentation could be more comprehensive

Code Comparison

ScrollReveal:

ScrollReveal().reveal('.headline', {
    delay: 500,
    distance: '50px',
    origin: 'bottom',
    duration: 1000
});

lax.js:

lax.addElements('.headline', {
    scrollY: {
        translateY: [
            ["elInY", "elCenterY", "elOutY"],
            [0, '-200', 0],
        ]
    }
});

Both libraries aim to create scroll-based animations, but they differ in approach. ScrollReveal focuses on revealing elements with predefined animations, while lax.js offers more flexibility in defining custom animations based on scroll position. ScrollReveal is generally easier to use for simple reveal animations, while lax.js provides more control for complex, multi-step animations. The code examples demonstrate the syntax difference, with ScrollReveal using a more declarative style and lax.js utilizing a more programmatic approach to define animations.

3,593

🚀 Performance focused, lightweight scroll animation library 🚀

Pros of Sal

  • Smaller file size (4.5KB vs 14KB for ScrollReveal)
  • Simpler API with fewer configuration options
  • Built-in support for CSS custom properties

Cons of Sal

  • Less actively maintained (last update 2 years ago vs 3 months for ScrollReveal)
  • Fewer animation options and customization possibilities
  • Less comprehensive documentation and examples

Code Comparison

ScrollReveal:

ScrollReveal().reveal('.element', {
  delay: 200,
  distance: '50px',
  origin: 'bottom',
  easing: 'cubic-bezier(0.5, 0, 0, 1)'
});

Sal:

sal({
  threshold: 0.5,
  once: false,
  animateClassName: 'sal-animate'
});

Both libraries aim to add scroll-based animations to web pages, but they differ in their approach and feature set. ScrollReveal offers more advanced options and customization, while Sal focuses on simplicity and lightweight implementation. ScrollReveal is more actively maintained and has a larger community, which may be beneficial for long-term support and updates. However, Sal's smaller file size and simpler API could be advantageous for projects with basic animation needs or performance constraints.

🛤 Detection of elements in viewport & smooth scrolling with parallax.

Pros of Locomotive Scroll

  • Offers smooth scrolling with parallax effects and custom easing
  • Provides advanced features like scroll-linked animations and horizontal scrolling
  • Actively maintained with regular updates and bug fixes

Cons of Locomotive Scroll

  • Larger file size and potentially higher performance overhead
  • Steeper learning curve due to more complex API and configuration options
  • May require additional setup for certain frameworks or build systems

Code Comparison

ScrollReveal:

ScrollReveal().reveal('.element', {
    delay: 200,
    distance: '50px',
    origin: 'bottom',
    duration: 1000
});

Locomotive Scroll:

const scroll = new LocomotiveScroll({
    el: document.querySelector('[data-scroll-container]'),
    smooth: true,
    lerp: 0.05,
    multiplier: 1.5
});

scroll.on('scroll', (instance) => {
    // Custom scroll handling
});

Both libraries offer scroll-based animations, but Locomotive Scroll provides more advanced features and customization options. ScrollReveal focuses on revealing elements as they enter the viewport, while Locomotive Scroll offers a complete scrolling experience with parallax effects and custom easing. The code examples demonstrate the difference in complexity and functionality between the two libraries.

Let your page react to scroll changes.

Pros of ScrollTrigger

  • More lightweight and focused on scroll-based animations
  • Offers more granular control over scroll-triggered events
  • Easier to implement custom animations and effects

Cons of ScrollTrigger

  • Less comprehensive documentation compared to ScrollReveal
  • Fewer built-in animation options out of the box
  • May require more custom JavaScript for complex animations

Code Comparison

ScrollTrigger:

const trigger = new ScrollTrigger({
  trigger: {
    once: false,
    offset: {
      element: {
        x: 0,
        y: (trigger, rect, direction) => {
          return 0.5
        }
      }
    }
  }
});

ScrollReveal:

ScrollReveal().reveal('.element', {
  delay: 200,
  distance: '50px',
  origin: 'bottom',
  opacity: 0,
  scale: 0.9
});

Both libraries offer ways to create scroll-based animations, but ScrollTrigger provides more flexibility in defining trigger points and custom behaviors. ScrollReveal, on the other hand, offers a simpler API with predefined animation options that are easier to implement for basic use cases.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

ScrollReveal


ScrollReveal

Animate elements as they scroll into view.

Build status Monthly downloads Version 5.7 kB min+gzip GPLv3 License


Installation

Browser

A simple and fast way to get started is to include this script on your page:

<script src="https://unpkg.com/scrollreveal"></script>

This will create the global variable ScrollReveal

Be careful using this method in production. Without specifying a fixed version number, Unpkg may delay your page load while it resolves the latest version. Learn more at unpkg.com

Module

$ npm install scrollreveal

CommonJS

const ScrollReveal = require('scrollreveal')

ES2015

import ScrollReveal from 'scrollreveal'

Usage

Installation provides us with the constructor function ScrollReveal(). Calling this function returns the ScrollReveal instance, the “brain” behind the magic.

ScrollReveal employs the singleton pattern; no matter how many times the constructor is called, it will always return the same instance. This means we can call it anywhere, worry-free.

There’s a lot we can do with this instance, but most of the time we’ll be using the reveal() method to create animation. Fundamentally, this is how to use ScrollReveal:

<h1 class="headline">
	Widget Inc.
</h1>
ScrollReveal().reveal('.headline')

🔎 See this demo live on JSBin



The full documentation can be found at https://scrollrevealjs.org

If you’re using an older version of ScrollReveal, you can find legacy documentation in the wiki



Commercial License Badge

License

For commercial sites, themes, projects, and applications, keep your source code private/proprietary by purchasing a Commercial License.

Licensed under the GNU General Public License 3.0 for compatible open source projects and non-commercial use.


Copyright 2023 Fisssion LLC

NPM DownloadsLast 30 Days