Skip to content

thesign3r/aoe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aoejs

Elevate your web projects to the next level with aoejs – the ultimate animation companion.

aoejs empowers you to effortlessly add stunning animations to elements as they gracefully enter and exit the viewport. Crafted with simplicity and performance in mind, this lightweight package leverages the power of the Intersection Observer API for seamless integration and blazing-fast animations.

With customizable options and a collection of pre-built CSS3 animations, aoejs is your go-to solution for captivating user experiences. Say hello to dynamic web design with aoejs!


Table of Contents

Install

Make sure to include aoe.css

<link rel="stylesheet" href="dist/aoe.css">
npm i aoejs
import Aoe from 'aoejs';

const aoe = new Aoe();
aoe.init();

Options

You can set options during initialization:

aoe.init({
  attributes: {
    dataset: "data-aoe",
    delay: "data-aoe-delay",
    speed: "data-aoe-speed",
  },
  observerRoot: null,
  observeRootMargin: "0px",
  observerThreshold: [0, 0.5, 0.75, 1],
  intersectionRatio: 0.5,
  once: false,
  speed: 1500,
  delay: 0,
  timingFunction: 'linear',
});
Property Type Description Default
once Boolean Defines if element should be animated every time it enters viewport. false
speed Int Defines animation speed on all elements - in ms null
delay Int Defines animation delay on all elements - in ms null
timing String Defines css timing function on all elements eg. ease-in null
intersectionRatio Node Tells how much of the target element needs to be visible within the root's intersection ratio in order to trigger animation 0.5
observerRoot Node root null/document
observeRootMargin string rootMargin 0px
observerThreshold number/array threshold [0, 0.5, 1]
attributes.dataset String You can change the data-aoe="" into data-custom="" null
attributes.delay String You can change the data-aoe-delay="" into custom-property-delay="" null
attributes.speed String You can change the data-aoe-speed="" into custom-property-speed="" null

Methods

Set callback for when element enters viewport

const aoe = new Aoe();
aoe.init();

aoe.onEnter((entry) => {
  console.log("Element entered viewport:", entry.target);
});

Set callback for when element leaves viewport

const aoe = new Aoe();
aoe.init();

aoe.onLeave((entry) => {
  console.log("Element left viewport:", entry.target);
});

Disconnect all observers

const aoe = new Aoe();
aoe.init();

aoe.disconnectObservers();

Usage

Add data-aoe attribute to your desired HTML elements.

<div data-aoe="popIn"></div>

With AOE you can easily affect animation speed and delay on individual items.

Simply add speed/delay into data-aoe attribute (in miliseconds):

<div data-aoe="popIn:1000:2000"></div>
<div data-aoe="popIn:duration:delay"></div>
<!-- or separately -->
<div data-aoe="popIn" data-aoe-delay="300" data-aoe-speed="100"></div>

Animations

AOE ships with many fancy CSS3 animations

  • swoopInTop
  • swoopInBottom
  • swoopInLeft
  • swoopInRight
  • popIn
  • popInTop
  • popInBottom
  • popInLeft
  • popInRight
  • hitLeft
  • hitRight
  • fadeIn
  • fadeInTop
  • fadeInBottom
  • fadeInLeft
  • fadeInRight
  • jumpInLeft
  • jumpInRight
  • driveInTop
  • driveInBottom
  • driveInLeft
  • driveInRight
  • ball
  • pull
  • pullLeft
  • pullRight
  • unfold
  • spinIn
  • flipInX
  • flipInY
  • rollIn

With AOE you can easily add your own, custom animations.

<div data-aoe="CustomAnimation"></div>
@keyframes CustomAnimation {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

.CustomAnimation {
    animation-name: CustomAnimation;
}

Note: You probably gonna need overflow-x: hidden on body / main

Note: Intersection Observer API does not work very old browsers! Make sure to:

Aoe should fallback to simple fadeIn animation if browser doesn't support it.

License

Created by Michał Gwóźdź. Released under the ISC License.

Author website: thesigner.dev

About

Animate On entrance (AOE) is a lightweight, dependency free, insanely fast scroll animation library built on top of Intersection Observer API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published