Giter Site home page Giter Site logo

gatsby-plugin-scroll-reveal's Introduction

gatsby-plugin-scroll-reveal ✨

npm version License: MIT

Gatsby plugin to animate DOM elements on scroll. Using Sal (Scroll Animation Library) focus on performance less than 2.8kb, written in vanilla Javascript.

To see how to use advanced options visit Sal's docs.

Note: Supported IE11

Install

yarn add gatsby-plugin-scroll-reveal

or

npm install --save gatsby-plugin-scroll-reveal

How to use

  1. Include the plugin in your gatsby-config.js file.
  2. Add your custom options object (optional)
// in gatsby-config.js
plugins: [
  `gatsby-plugin-scroll-reveal`
];

Options

Here is a full list of options with their default values you can use to configure this plugin.

// in gatsby-config.js
plugins: [
  {
    resolve: `gatsby-plugin-scroll-reveal`,
    options: {
        threshold: 1, // Percentage of an element's area that needs to be visible to launch animation
        once: true, // Defines if animation needs to be launched once
        disable: false, // Flag for disabling animations
        
        // Advanced Options
        selector: '[data-sal]', // Selector of the elements to be animated
        animateClassName: 'sal-animate', // Class name which triggers animation
        disabledClassName: 'sal-disabled', // Class name which defines the disabled state
        rootMargin: '0% 50%' // Corresponds to root's bounding box margin
        enterEventName: 'sal:in' // Enter event name
        exitEventName: 'sal:out' // Exit event name
    }
  }
];

Usage

It will look for all HTML elements with a data-sal attribute and launch their animation when in viewport.

  • data-sal - attribute with the animation name as value - required
  • data-sal-duration - changes duration of the animation - optional
  • data-sal-delay - adds delay to the animation - optional
  • data-sal-easing - sets easing for the animation - optional

For example:

<div
  data-sal="slide-up"
  data-sal-delay="300"
  data-sal-easing="ease"
></div>

The library supports:

  • fade
  • slide-up
  • slide-down
  • slide-left
  • slide-right
  • zoom-in
  • zoom-out
  • flip-up
  • flip-down
  • flip-left
  • flip-right

Gatsby v1

This plugin is not compatible anymore with Gatsby v1, you should update to the version 2.0.0.

License

Created by Soluble Studio. Released under the MIT License.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.