The easiest way to animate your Next.js project. Scrollreveal.js helper package.

Overview

next-reveal

The easiest way to animate your Next.js app

Demo

Introduction

next-reveal makes it easy to add awesome scroll animations to your Next.js project.

If you want to learn more about Scrollreveal.js the full documentation can be found at https://scrollrevealjs.org

  • 🐧 ⭐ If you like this project give me a Star ⭐ 🐧

Installation

npm i next-reveal

or

yarn add next-reveal

Usage

RevealWrapper

You can animate single elements with RevealWrapper, just wrap your component inside RevealWrapper and base animate will be applied.

Base usage

import RevealWrapper from  'next-reveal'
<RevealWrapper>
	<h1  className={styles.title}>
		Welcome to <a  href="https://nextjs.org">Next.js!</a>
	</h1>
</RevealWrapper>

Custum animation

<RevealWrapper rotate={{x:  12,y:40,z:0}} origin='left' delay={200} duration={1000} distance='500px' reset={true} viewOffset={{top:  25,  right:0,  bottom:  10,  left:5}}>
	<h1  className='text-blue-700 text-6xl leading-5 mt-36'>Welcome to <a  className='focus:underline active:underline hover:underline'  href="https://github.com/ritmillio/next-reveal">next-reveal!</a></h1>
	<p  className='text-sm mt-5 ml-2'>A package based on ScrollReveal</p>
</RevealWrapper>

RevealList

You can animate multiple elements which will result a sequence animation.

Basic usage Note that in RevealList you need to specify at least the delay and interval

import RevealList from  'next-reveal'
<RevealList interval={60} delay={500}  className='flex flex-wrap items-center justify-center'>
	<div className='bg-blue-400 h-12 w-12 xl:h-16 xl:w-16 m-2'></div>
	<div className='bg-blue-400 h-12 w-12 xl:h-16 xl:w-16 m-2'></div>
	<div className='bg-blue-400 h-12 w-12 xl:h-16 xl:w-16 m-2'></div>
	<div className='bg-blue-400 h-12 w-12 xl:h-16 xl:w-16 m-2'></div>
</RevealList>

See live demo next-reveal-site


Options/Animations

Option Type Description
delay number delay is the time before reveal animations begin.
distance string distance controls how far elements move when revealed.
duration number duration controls how long animations take to complete.
easing string easing controls how animations transition between their start and end values.
interval number interval is the time between each reveal.
opacity `number null`
origin string origin specifies what direction elements come from when revealed.
rotate object rotate specifies the rotation elements have prior to being revealed.
scale number scale specifies the size of elements have prior to being revealed.
desktop boolean desktop enables/disables animations on desktop browsers.
mobile boolean mobile enables/disables animations on mobile browsers.
reset boolean reset enables/disables elements returning to their initialized position when they leave the viewport. When true elements reveal each time they enter the viewport instead of once.
useDelay string useDelay specifies when values assigned to options.delay are used.
viewFactor number viewFactor specifies what portion of an element must be within the viewport for it to be considered visible.
viewOffset object viewOffset expands/contracts the active boundaries of the viewport when calculating element visibility.

Defaults

const defaultRevealOptions  = {
delay:  350,
distance:  '50px',
duration:  650,
easing:  'cubic-bezier(0.5, 0, 0, 1)',
opacity:  0,
origin:  'top',
rotate: {
	x:  0,
	y:  0,
	z:  0,
},
scale:  1,
cleanup:  false,
desktop:  true,
mobile:  true,
reset:  false,
useDelay:  'always',
viewFactor:  0.0,
viewOffset: {
		top:  0,
		right:  0,
		bottom:  0,
		left:  0,
	},
}

Prevent Flickering

If you experience Flickering you can create helper css class to make RevealWrapper element or RevealList items visibility:hidden which will prevent flickering.

Step 1:

Create a _document.tsx file in your pages directory if you don't have one. Inside your _document.tsx file you need to add sr class to the Html tag

import Document, { Html, Head, Main, NextScript } from 'next/document'

class MyDocument extends Document {
  static async getInitialProps(ctx:any) {
    const initialProps = await Document.getInitialProps(ctx)
    return { ...initialProps }
  }

  render() {
    return (
      <Html lang='en' className='sr'>
        <Head></Head>
        <body>
          <Main />
          <NextScript />
        </body>
      </Html>
    )
  }
}

export default MyDocument

Step 2:

Add helper classes to your global.css file

html.sr .load-hidden {
 visibility: hidden;
}

Step 3:

Add your load-hidden class to your elements where you use RevealWrapper or RevealList

<RevealWrapper className="load-hidden" rotate={{x: 12,y:40,z:0}} origin='left' delay={200} duration={1000} distance='500px' reset={true} viewOffset={{top: 25, right:0, bottom: 10, left:5}}>
	<h1 className='text-blue-700 text-6xl leading-5 mt-36'>
		Welcome to <a className='focus:underline active:underline hover:underline' href="https://github.com/ritmillio/next-reveal">next-reveal!</a>
	</h1>
	<p className='text-sm mt-5 ml-2'>A package based on ScrollReveal</p>
</RevealWrapper>
<RevealList interval={60} delay={500} className='flex flex-wrap items-center justify-center'>
	<div className='load-hidden bg-blue-400 h-12 w-12 xl:h-16 xl:w-16 m-2'></div>
	<div className='load-hidden bg-blue-400 h-12 w-12 xl:h-16 xl:w-16 m-2'></div>
	<div className='load-hidden bg-blue-400 h-12 w-12 xl:h-16 xl:w-16 m-2'></div>
	<div className='load-hidden bg-blue-400 h-12 w-12 xl:h-16 xl:w-16 m-2'></div>
</RevealList>

License

Since this package is using Scrollreveal.js, in case of commercial use check out their Commercial License

You might also like...

A REST helper for Next.js APIs

REST controller for Next.js How does it work? Create restful controllers in Next.js Example: Inside /pages/api/auth/[...handler] (filename must be a r

Jul 30, 2022

Shizuku Launcher is a simple AWS Virtual Machine helper. Now in Next.js

Shizuku Launcher Shizuku Launcher is a simple AWS Virtual Machine helper. Shizuku Launcher offers multiple solutions to keep your credential security

Jan 3, 2023

Catalogist is the easy way to catalog and make your software and (micro)services visible to your organization in a lightweight and developer-friendly way.

Catalogist is the easy way to catalog and make your software and (micro)services visible to your organization in a lightweight and developer-friendly way.

catalogist πŸ“š πŸ““ πŸ“’ πŸ“– πŸ”– The easy way to catalog and make your software and (micro)services visible to your organization through an API You were a pe

Dec 13, 2022

🎨 Beautify your github profile with this amazing tool, creating the readme your way in a simple and fast way πŸš€ The best profile readme generator you will find ⚑

🎨 Beautify your github profile with this amazing tool, creating the readme your way in a simple and fast way πŸš€ The best profile readme generator you will find ⚑

Demo Profile Readme Generator The best profile readme generator you will find! About | Technologies | Requirements | Starting | Contributing 🎯 About

Jan 1, 2023

The easiest quiz night you'll ever run.

The easiest quiz night you'll ever run.

Quizzler The easiest quiz night you'll ever run. About The Project Quizzler is a fun new way to practice, improve, and test your Javascript skills. Du

Dec 4, 2022

Animate your Alpine components.

Animate your Alpine components πŸš€ This package provides you with a simple helper to animate your ALpine.js components. Installation The recommended wa

Nov 16, 2022

"Jira Search Helper" is a project to search more detail view and support highlight than original jira search

Jira Search Helper What is Jira Search Helper? "Jira Search Helper" is a project to search more detail view and support highlight than original jira s

Dec 23, 2022

Animate on scroll library

❗ ❗ ❗ This is README for aos@next ❗ ❗ ❗ For last stable release (v2) go here πŸš€ Demo 🌟 Codepen Examples Different built-in animations With anchor set

Jan 2, 2023

animate.css as a Tailwind plugin

tailwind-animatecss Use animate.css as a Tailwind 3 plugin. Demo – https://dumptyd.github.io/tailwind-animatecss Table of contents Installation Usage

Dec 19, 2022
Easiest 1-click way to install and use Stable Diffusion on your own computer. Provides a browser UI for generating images from text prompts and images. Just enter your text prompt, and see the generated image.

Stable Diffusion UI Easiest way to install and use Stable Diffusion on your own computer. No dependencies or technical knowledge required. 1-click ins

null 3.5k Dec 30, 2022
Um bot de suporte feito usando threads para o Discord, 100% customizΓ‘vel, feito em JavaScript e inspirado no Rio Helper do servidor Elixir Lab e na Loritta Helper do serivdor de suporte da Loritta.

Ticket Bot Um bot de suporte feito usando threads para o Discord, 100% customizΓ‘vel, feito em JavaScript e inspirado no Rio Helper do servidor Elixir

ADG 6 Dec 21, 2022
Wonka JS is the easiest way to mint Metaplex's Candy Machine NFTs with APIs.

Wonka JS Wonka JS is the easiest way to mint from Candy Machine and fetch NFTs through JS APIs. You can see an end to end example in Next.js demo proj

Wonka Labs 71 Nov 3, 2022
🎊 The easiest way to use MineAPI.

@mineapi/sdk Do you need my help? Visit our Discord server. Node Version: 16.16.0 Installation npm i @mineapi/sdk --save # or yarn add @mineapi/sdk Us

MineAPI 5 Jul 29, 2022
The Easiest Way To Write Twitter Threads 🐦

Twotion | The Easiest Way To Write Twitter Threads Write Twitter threads and post them in one click without leaving Notion. Completely Free No Need To

Osada Vidath Chandrasekara 9 Nov 24, 2022
The easiest way to record audio on the web :speaker:

BoothJS (or booth.js) is a zero-dependency, extensible wrapper around the Web Audio API that makes recording audio on the web super easy. Booth fully

Tyler Nickerson 7 Dec 15, 2022
An easy way to animate SVG elements.

Walkway I loved the animations for the polygon ps4 review a few months back and decided to create a small library to re-create them (simple demo). It

Connor Atherton 4.4k Jan 2, 2023
A small helper package for discord.js users

helper-djs Helper Djs is a powerful Node.js module Features Error Handler Auto Meme Requirement node v16.14 Installation npm install helper-djs Bot Se

Aadhu 4 Aug 9, 2022
Helper package to handle requests to a jschan api instance.

jschan-api-sdk Helper package to handle requests to a jschan api instance. How to use npm install ussaohelcim/jschan-api-sdk const { jschan } = requir

Michell 3 Jun 30, 2022
Package fetcher is a bot messenger which gather npm packages by uploading either a json file (package.json) or a picture representing package.json. To continue...

package-fetcher Ce projet contient un boilerplate pour un bot messenger et l'executable Windows ngrok qui va permettre de crΓ©er un tunnel https pour c

AILI Fida Aliotti Christino 2 Mar 29, 2022