1.0.3 • Published 5 months ago

@fvastu/animated-on-scroll-stack v1.0.3

Weekly downloads
-
License
GPL-3.0
Repository
github
Last release
5 months ago

Introduction

animated-on-scroll-stack simplifies the process of incorporating captivating scroll animations into your Next.js project, seamlessly integrating with all ChakraUI properties. This project is a union between the ideas from next-reveal and the power of ChakraUI.

Why AnimatedOnScrollStack?

  • ✨ Easily animate ChakraUI elements with captivating scroll animations.
  • 🚀 Seamless integration with ChakraUI, leveraging its powerful features.
  • 📚 Inspired by Scrollreveal.js – for more details, refer to https://scrollrevealjs.org.
  • 🐧 ⭐ If you find this project helpful, give it a star ⭐ 🐧

Installation

npm i @fvastu/animated-on-scroll-stack

or

yarn add  @fvastu/animated-on-scroll-stack

Usage

AnimatedOnScrollStack

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

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

'use client'

import { AnimatedOnScrollStack } from "@fvastu/animated-on-scroll-stack";
<AnimatedOnScrollStack interval={60} delay={500}  className='flex flex-wrap items-center justify-center'>
  <Card className='bg-blue-400 h-12 w-12 xl:h-16 xl:w-16 m-2'></Card>
  <Card className='bg-blue-400 h-12 w-12 xl:h-16 xl:w-16 m-2'></Card>
  <Card className='bg-blue-400 h-12 w-12 xl:h-16 xl:w-16 m-2'></Card>
  <Card className='bg-blue-400 h-12 w-12 xl:h-16 xl:w-16 m-2'></Card>
</AnimatedOnScrollStack>

Options/Animations

OptionTypeDescription
delaynumberdelay is the time before reveal animations begin.
distancestringdistance controls how far elements move when revealed.
durationnumberduration controls how long animations take to complete.
easingstringeasing controls how animations transition between their start and end values.
intervalnumberinterval is the time between each reveal.
opacitynumber | nullopacity specifies the opacity they have prior to being revealed.
originstringorigin specifies what direction elements come from when revealed.
rotateobjectrotate specifies the rotation elements have prior to being revealed.
scalenumberscale specifies the size of elements have prior to being revealed.
desktopbooleandesktop enables/disables animations on desktop browsers.
mobilebooleanmobile enables/disables animations on mobile browsers.
resetbooleanreset 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.
useDelaystringuseDelay specifies when values assigned to options.delay are used.
viewFactornumberviewFactor specifies what portion of an element must be within the viewport for it to be considered visible.
viewOffsetobjectviewOffset 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,
	},
}

License

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