High-performance JavaScript animation library with TypeScript support providing DOM animations, transforms, UI effects, and comprehensive easing functions.
—
Velocity provides 78 pre-built animation sequences organized into categories for common interface animations. These sequences combine multiple property animations with optimized timing and easing.
function Velocity(
elements: VelocityElements,
sequence: string,
options?: VelocityOptions
): VelocityResult;
function Velocity(
elements: VelocityElements,
sequence: string,
duration?: number,
complete?: VelocityCallbackFn
): VelocityResult;Animations designed to draw attention to elements without changing their position in the layout.
interface AttentionSeekers {
bounce: SequenceList;
flash: SequenceList;
headShake: SequenceList;
jello: SequenceList;
pulse: SequenceList;
rubberBand: SequenceList;
shake: SequenceList;
swing: SequenceList;
tada: SequenceList;
wobble: SequenceList;
}Bounces the element up and down with decreasing intensity.
Rapidly toggles opacity to create a flashing effect.
Shakes the element horizontally like a "no" gesture.
Creates a jello-like wobble with elastic distortion.
Smoothly scales the element up and down.
Stretches and contracts the element like a rubber band.
Rapidly moves the element left and right.
Rotates the element back and forth like a pendulum.
Combines scaling and rotation for a celebratory effect.
Creates an irregular wobbling motion.
Elements bounce in from off-screen positions with elastic landing effects.
interface BouncingEntrances {
bounceIn: SequenceList;
bounceInDown: SequenceList;
bounceInLeft: SequenceList;
bounceInRight: SequenceList;
bounceInUp: SequenceList;
}Scales element from 0 to full size with bouncing motion.
Element bounces in from above the viewport.
Element bounces in from the left side.
Element bounces in from the right side.
Element bounces in from below the viewport.
Elements bounce out to off-screen positions with elastic departure effects.
interface BouncingExits {
bounceOut: SequenceList;
bounceOutDown: SequenceList;
bounceOutLeft: SequenceList;
bounceOutRight: SequenceList;
bounceOutUp: SequenceList;
}Scales element down to 0 with bouncing motion.
Element bounces out downward off-screen.
Element bounces out to the left side.
Element bounces out to the right side.
Element bounces out upward off-screen.
Elements fade in while moving from off-screen positions.
interface FadingEntrances {
fadeIn: SequenceList;
fadeInDown: SequenceList;
fadeInDownBig: SequenceList;
fadeInLeft: SequenceList;
fadeInLeftBig: SequenceList;
fadeInRight: SequenceList;
fadeInRightBig: SequenceList;
fadeInUp: SequenceList;
fadeInUpBig: SequenceList;
}Simple opacity fade from 0 to 1.
Fades in while moving from above.
Fades in from far above with larger movement distance.
Fades in while moving from the left.
Fades in from far left with larger movement distance.
Fades in while moving from the right.
Fades in from far right with larger movement distance.
Fades in while moving from below.
Fades in from far below with larger movement distance.
Elements fade out while moving to off-screen positions.
interface FadingExits {
fadeOut: SequenceList;
fadeOutDown: SequenceList;
fadeOutDownBig: SequenceList;
fadeOutLeft: SequenceList;
fadeOutLeftBig: SequenceList;
fadeOutRight: SequenceList;
fadeOutRightBig: SequenceList;
fadeOutUp: SequenceList;
fadeOutUpBig: SequenceList;
}Similar to fading entrances but in reverse - elements fade out while moving off-screen.
3D flip animations around different axes.
interface Flippers {
flip: SequenceList;
flipInX: SequenceList;
flipInY: SequenceList;
flipOutX: SequenceList;
flipOutY: SequenceList;
}Generic flip animation with 3D rotation.
Flips in around the X-axis (horizontal flip).
Flips in around the Y-axis (vertical flip).
Flips out around the X-axis.
Flips out around the Y-axis.
High-speed animations with skewing effects.
interface Lightspeed {
lightSpeedIn: SequenceList;
lightSpeedOut: SequenceList;
}Fast entry with skewing effect simulating light speed.
Fast exit with skewing effect.
Elements rotate in from off-screen positions.
interface RotatingEntrances {
rotateIn: SequenceList;
rotateInDownLeft: SequenceList;
rotateInDownRight: SequenceList;
rotateInUpLeft: SequenceList;
rotateInUpRight: SequenceList;
}Rotates in with scaling from center.
Rotates in from the down-left corner.
Rotates in from the down-right corner.
Rotates in from the up-left corner.
Rotates in from the up-right corner.
Elements rotate out to off-screen positions.
interface RotatingExits {
rotateOut: SequenceList;
rotateOutDownLeft: SequenceList;
rotateOutDownRight: SequenceList;
rotateOutUpLeft: SequenceList;
rotateOutUpRight: SequenceList;
}Similar to rotating entrances but in reverse.
Elements slide in from off-screen positions.
interface SlidingEntrances {
slideInDown: SequenceList;
slideInLeft: SequenceList;
slideInRight: SequenceList;
slideInUp: SequenceList;
}Slides in from above the viewport.
Slides in from the left side.
Slides in from the right side.
Slides in from below the viewport.
Elements slide out to off-screen positions.
interface SlidingExits {
slideOutDown: SequenceList;
slideOutLeft: SequenceList;
slideOutRight: SequenceList;
slideOutUp: SequenceList;
}Similar to sliding entrances but in reverse.
Unique animations with special effects.
interface Specials {
hinge: SequenceList;
jackInTheBox: SequenceList;
rollIn: SequenceList;
rollOut: SequenceList;
}Simulates a door swinging on a hinge.
Pops up like a jack-in-the-box toy.
Rolls in with rotation and translation.
Rolls out with rotation and translation.
Elements zoom in from off-screen positions.
interface ZoomingEntrances {
zoomIn: SequenceList;
zoomInDown: SequenceList;
zoomInLeft: SequenceList;
zoomInRight: SequenceList;
zoomInUp: SequenceList;
}Scales up from 0 to full size.
Zooms in while moving from above.
Zooms in while moving from the left.
Zooms in while moving from the right.
Zooms in while moving from below.
Elements zoom out to off-screen positions.
interface ZoomingExits {
zoomOut: SequenceList;
zoomOutDown: SequenceList;
zoomOutLeft: SequenceList;
zoomOutRight: SequenceList;
zoomOutUp: SequenceList;
}Similar to zooming entrances but in reverse.
interface SequenceList {
duration: number;
[sequenceStep: number]: Properties<any>;
}
type VelocitySequence =
| string
| SequenceList
| Array<Properties<any>>;import Velocity from "velocity-animate";
// Simple attention seeker
Velocity(element, "bounce");
// Entrance animation
Velocity(element, "fadeInUp", { duration: 800 });
// Exit animation with callback
Velocity(element, "slideOutLeft", {
duration: 600,
complete: () => element.style.display = "none"
});// Entrance -> attention -> exit sequence
Velocity(element, "bounceIn", 600)
.then(() => new Promise(resolve => setTimeout(resolve, 1000)))
.then(() => Velocity(element, "pulse", 400))
.then(() => Velocity(element, "fadeOut", 500));// Override default duration
Velocity(element, "rubberBand", {
duration: 1200, // Slower than default
loop: 2, // Repeat twice
delay: 300 // Start after delay
});
// Multiple elements with stagger
Velocity(elements, "slideInUp", {
duration: 800,
stagger: 150, // 150ms between each element
easing: "easeOutBounce"
});// Register a custom sequence
Velocity.Sequences.customWiggle = {
duration: 1000,
0: { rotateZ: "0deg" },
25: { rotateZ: "5deg" },
50: { rotateZ: "-5deg" },
75: { rotateZ: "3deg" },
100: { rotateZ: "0deg" }
};
// Use the custom sequence
Velocity(element, "customWiggle");// Use different variations of similar sequences
Velocity(element1, "fadeIn"); // Simple fade
Velocity(element2, "fadeInUp"); // Fade with upward motion
Velocity(element3, "fadeInUpBig"); // Fade with large upward motion
// Compare different entrance styles
Velocity(element1, "bounceInLeft"); // Bouncy entrance
Velocity(element2, "slideInLeft"); // Smooth entrance
Velocity(element3, "zoomInLeft"); // Scaling entrance// Different sequences based on screen size
const isMobile = window.innerWidth < 768;
if (isMobile) {
// Simpler animations for mobile
Velocity(element, "fadeIn", { duration: 400 });
} else {
// More elaborate animations for desktop
Velocity(element, "bounceInDown", { duration: 800 });
}Install with Tessl CLI
npx tessl i tessl/npm-velocity-animate