High-performance JavaScript animation library with TypeScript support providing DOM animations, transforms, UI effects, and comprehensive easing functions.
npx @tessl/cli install tessl/npm-velocity-animate@2.0.0Velocity is a high-performance JavaScript animation library that provides accelerated DOM animation, CSS transforms, color animations, scroll animations, and physics-based easing. Built with TypeScript, it offers comprehensive animation capabilities with zero dependencies and cross-browser compatibility, serving as a modern alternative to jQuery animations.
npm install velocity-animateimport Velocity from "velocity-animate";For CommonJS:
const Velocity = require("velocity-animate");For ES6 named imports:
import { Velocity } from "velocity-animate";For TypeScript with types:
import Velocity, { VelocityOptions, VelocityResult } from "velocity-animate";import Velocity from "velocity-animate";
// Basic animation - fade in an element
Velocity(element, { opacity: 1 }, { duration: 1000 });
// Chain multiple animations
Velocity(element, { translateX: "200px" }, { duration: 500 })
.then(() => Velocity(element, { rotateZ: "45deg" }, { duration: 300 }));
// Use predefined UI sequences
Velocity(element, "fadeIn", { duration: 600 });
// Method chaining (when patched)
element.velocity({ left: "200px" }, 1000)
.velocity({ rotateY: "45deg" }, 500);Velocity is organized around several core systems:
Primary animation functionality for CSS properties, transforms, and custom properties. Supports chaining, promises, and advanced timing control.
function Velocity(
elements: VelocityElements,
properties: Properties<any>,
options?: VelocityOptions
): VelocityResult;
function Velocity(
elements: VelocityElements,
properties: Properties<any>,
duration?: number,
complete?: VelocityCallbackFn
): VelocityResult;Control and introspection actions for managing running animations, getting/setting properties, and animation state management.
function Velocity(elements: VelocityElements, action: "stop", queue?: string): VelocityResult;
function Velocity(elements: VelocityElements, action: "pause"): VelocityResult;
function Velocity(elements: VelocityElements, action: "resume"): VelocityResult;
function Velocity(elements: VelocityElements, action: "finish", queue?: string): VelocityResult;
function Velocity(elements: VelocityElements, action: "reverse"): VelocityResult;Comprehensive easing function library including linear, swing, CSS standard easings, and physics-based easings for natural motion.
interface VelocityEasings {
linear: VelocityEasingFn;
swing: VelocityEasingFn;
ease: VelocityEasingFn;
"ease-in": VelocityEasingFn;
"ease-out": VelocityEasingFn;
"ease-in-out": VelocityEasingFn;
// ... 30+ total easing functions
}Pre-built animation sequences organized into categories like attention seekers, entrances, exits, and special effects. Perfect for common interface animations.
function Velocity(
elements: VelocityElements,
sequence: string,
options?: VelocityOptions
): VelocityResult;
interface VelocitySequences {
// Attention Seekers (10)
bounce: SequenceList;
flash: SequenceList;
pulse: SequenceList;
shake: SequenceList;
// ... 78 total sequences
}Global configuration options, state management, debugging tools, and utility functions for extending Velocity's capabilities.
interface VelocityStatic {
version: string;
defaults: StrictVelocityOptions & { reset?: () => void };
State: VelocityState;
debug: boolean | 1 | 2;
mock: boolean;
patch: (target: any, addGlobal?: boolean) => void;
}Core interfaces and type definitions used throughout the Velocity API:
interface VelocityOptions {
duration?: number | "fast" | "normal" | "slow";
easing?: VelocityEasingType;
queue?: string | false;
begin?: VelocityCallbackFn;
progress?: VelocityProgressFn;
complete?: VelocityCallbackFn;
display?: string | "auto" | "inline" | "block" | "inline-block" | "flex" | "none";
visibility?: "hidden" | "visible" | "collapse";
loop?: boolean | number;
delay?: number;
mobileHA?: boolean;
}
interface VelocityResult extends Array<HTMLorSVGElement> {
velocity: typeof Velocity;
then?: (resolve: (value?: any) => void, reject?: (reason?: any) => void) => VelocityResult;
}
type VelocityElements =
| HTMLorSVGElement
| HTMLorSVGElement[]
| NodeList
| HTMLCollection
| VelocityResult
| string;
type HTMLorSVGElement = HTMLElement | SVGElement;