An open API service indexing awesome lists of open source software.

https://github.com/michal-skoula/simple-scroll-animations

Simple lightweight CSS library for animating on scroll with Tailwind inspired syntax.
https://github.com/michal-skoula/simple-scroll-animations

animation css-animations css-library library lightweight scroll-animations

Last synced: about 1 year ago
JSON representation

Simple lightweight CSS library for animating on scroll with Tailwind inspired syntax.

Awesome Lists containing this project

README

          

# Simple scroll animations
![Showcase video](assets/videos/showcase.gif)

- 🌐 [Demo website](https://michal-skoula.github.io/simple-scroll-animations)
- 🔗 [My WIP personal website using this library](https://michal-skoula.github.io/website-design)
- 🗃️ [Product Hunt](https://www.producthunt.com/posts/scroll-animations-css-library)

Tailwind inspired way to create simple scroll animations for your website. Extremely easy to use for someone who wants to spice up their website presentation.

I made this for my personal website, as I really only needed simple animations and this was the most comfortable way I found of making them.
``` HTML

And that's it!


```
## 💎 Highlights
- Every setting fully customizable
- Super simple to use, only need to remember a few classes
- Mostly CSS only and utilizing the intersectionObserver API for applying the animations

## 🏗️ Installation
### 1. Link CSS and JS in your project
Add the following code in ``:
``` HTML

```
### 2. Add `animate` class to elements you want to animate
``` HTML

This is now animated!


```
### 3. Add aditional classes to modify the behaviour
``` HTML

Left to right animation with a delay happening once


```
*For a more detailed overview of available classes, see **Configuration**.*

### 4. Change settings to suit your preferences
This library comes with a few settings to tweak to your liking, which you change by editing CSS variables inside the document `:root`. You can copy the following code inside your CSS should you want to change any values. **You do not need to change any of these values if you don't want to.**
``` CSS
:root:root {
--reanimate-on-scroll-by-default: 0;
--default-animation-duration: 500ms;
--staggered-step-amount:250ms;
--delay-step-amount: 250ms;
--blur-strength: 3px;
--translate-amount-x: 40%;
--translate-amount-y: 40%;
}
```
Note: In order to change these setting, use `:root:root` for a higher specificity than the default settings.

A more detailed description of the available settings can be seen in **Configuration**.

## ⚙️ Configuration
### Notes
If your element has animations and transitions on it already, this library may not play nice. I recommend wrapping the element in a `

` or `` and putting the animations on that to resolve any issues.
#### ❌ Don't:
``` HTML
Button
```
#### ✅ Do:
``` HTML

```

### Settings
``` CSS
:root {
/* Sets if by default animations should play every time they are loaded (1) or only once (0) */
--reanimate-on-scroll-by-default: 1;

/* Default duration for all animations. Can be overriden by setting a duration100-1000 value. */
--default-animation-duration: 500ms;

/* For duration100-1000, what the step values should be. */
/* For a value of200ms, duration200 = 400ms, duration300 = 600ms and so on. */
/* Equation is: calc(var(--staggered-step-amount) * var(--duration)); */
--staggered-step-amount:250ms;

/* Sets the values for each step of the animation in a list and delay100-1000 values. */
/* For a value of 150ms, delay100 = 150ms, delay300 = 450ms and so on. */
/* Equation is: calc(var(--delay-step-amount) * var(--delay) */
--delay-step-amount: 250ms;

/* How strong the blur is when elements are animating in. Can be turned off. */
--blur-strength: 3px;

/* How much elements should be moved when animated e.g. right-to-left. */
--translate-amount-x: 40%;
--translate-amount-y: 40%;
}
```
### Available animation types
- `fade-in` (default)
- `right-to-left`
- `left-to-right`
- `top-to-bottom`
- `bottom-to-top`

### Available Classes
- `animate` - Makes an element be animatable. This is mandatory for every element that is to be animated.
- `name-of-animation` - Type of animation which should display on scroll, see **Animation types**.
- `once / always` - If the animation should play once or every time it enters the viewport.
- `staggered`- Used on lists of elements, such as cards, buttons, menu items etc.
- `noblur` - Removes blur from the animation.
- `delay100-1000` - Set a custom delay for when the animation should play for. Doesn't work with `staggered`.
- `duration100-1000` - Set a custom duration for how long the animation should play for.

## 🌳 Examples
### Different directions
![Directions](assets/videos/directions.gif)
``` HTML

All cardinal directions!









```
---
### Staggered elements (cards or lists)
![Staggered](assets/videos/staggered.gif)
``` HTML

Sick staggered cards with one class









```
---
### Delayed animations
![Delayed](assets/videos/delay.gif)
``` HTML

Easily set a delay



You
just
set
a
value
from
100
to
1000


```
---
### Long and short animations
![Duration](assets/videos/duration.gif)
``` HTML

Set an animation duration


Your animation can be as short or as long as you'd like



```