Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
animate-css-grid
Advanced tools
Seamlessly animate all CSS grid properties, including:
grid-column
and grid-row
grid-template-columns
grid-gap
This script makes it easy to transition your CSS grid gracefully from one state to another. If the content of the grid changes, or if the grid or one of its children is updated with the addition or removal of a class, the grid will automatically transition to its new configuration.
Just call the wrapGrid
method on your grid container, and optionally provide a config object as a second argument.
If the grid is removed from the page, the animations will automatically be cleaned up as well.
ES6 Module:
yarn add animate-css-grid
or npm install animate-css-grid
import { wrapGrid } from animateCSSGrid
const grid = document.querySelector(".grid");
wrapGrid(grid);
Or from a script tag:
<script src="https://unpkg.com/animate-css-grid@latest"></script>
<script>
const grid = document.querySelector(".grid");
animateCSSGrid.wrapGrid(grid, {duration : 600});
</script>
Optional config object:
{
// int: default is 0 ms
stagger: 100,
// int: default is 250 ms
duration: 500
// string: default is 'easeInOut'
easing: 'backInOut'
}
Available easing functions:
'linear'
'easeIn'
/ 'easeOut'
/ 'easeInOut'
'circIn'
/ 'circOut'
/ 'circInOut'
'backIn'
/ 'backOut'
/ 'backInOut'
'anticipate'
Learn more about available easing functions here.
Two functions are returned by the wrapGrid
call that you probably won't need to use:
import { wrapGrid } from animateCSSGrid
const grid = document.querySelector(".grid");
const { unwrapGrid, forceGridAnimation } = wrapGrid(grid);
// if you want the grid to transition after updating an inline style
// you need to call forceGridAnimation
grid.style.width = '500px'
forceGridAnimation()
// if you want to remove animations but not the grid itself
unwrapGrid()
forceGridAnimation()
)Example:
<!-- grid class -->
<ul class="some-grid-class-that-changes">
<li class="grid-item">
<!-- each grid item must have a single direct child -->
<div>
<h3>Item title</h3>
<div>Item body</div>
</div>
</li>
<div>
The script registers a MutationObserver
that activates when the grid or one of its children adds or loses a class or element. That means there's no need to remove the animations before removing the grid, everything should be cleaned up automatically.
It uses the FLIP animation technique to smoothly update the grid, applying a counter transform to the children of each item so that they do not appear distorted while the transition occurs.
It should work on container elements without CSS grid applied as well, but was developed and tested with CSS grid in mind.
The animate-css-grid
library can easily be used with frameworks like React.
Check out an example on Codepen.
FAQs
Buttery smooth, easy transitions for CSS grid
The npm package animate-css-grid receives a total of 4,795 weekly downloads. As such, animate-css-grid popularity was classified as popular.
We found that animate-css-grid demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.