Velocity.js is a high-performance JavaScript animation library that provides a feature-rich and fast alternative to traditional methods like jQuery's `$.animate()` or basic CSS transitions. It enables complex UI motion design by optimizing DOM interactions to minimize layout thrashing and leveraging efficient JavaScript animation techniques. Key features include support for color animations, CSS transforms, loops, easings, SVG properties, and scrolling. Velocity.js offers an API that closely mirrors jQuery's `$.animate()`, allowing for seamless integration with or independent use from jQuery. The library is currently stable at version 2.0.6, released in September 2023, demonstrating ongoing maintenance and development. This version integrated the former `UI-Pack` animations directly into its core and introduced a Promise-based API for modern asynchronous control flow. It aims to deliver significantly smoother animations, especially on mobile devices, by focusing on performance at its core.
npm install velocity-animateVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates animating a DOM element using Velocity.js ES module import. It shows basic property animation, chaining with Promises, custom easing, looping, and parallel animations.
Refer to the official V2_CHANGES.md documentation for a detailed migration guide, as many options and behaviors were altered.
Remove separate imports or script tags for `velocity.ui.js`. Animations previously provided by the UI-Pack are now accessible directly through the main `Velocity` object.
Adopt `.then()` or `async/await` syntax for managing animation sequences and completion, instead of relying solely on `complete` callbacks.
Ensure consistent module usage throughout your project. For Node.js, either configure your `package.json` with `"type": "module"` for ESM, or stick to CommonJS `require()` and ensure packages are correctly transpiled or built for dual module support.
For optimal performance and bundle size, if using Velocity without jQuery's animation module, custom-build jQuery to exclude its `effects` module.
For ES Modules, use `import Velocity from 'velocity-animate';`. For CommonJS, use `const Velocity = require('velocity-animate');`. If using a script tag, ensure `velocity.js` is loaded before your animation code, and `Velocity` will be available globally.If you intend to use jQuery, ensure jQuery is loaded *before* Velocity.js. If not using jQuery, animate raw DOM elements directly using `Velocity(element, properties, options);` rather than attempting to call `.velocity()` as a method on the element itself or a jQuery object.
No dependency data recorded yet.