Velocity (JavaScript library) explained

Velocity
Author:Julian Shapiro
Latest Release Version:1.5.2[1]
Latest Release Date:July 31st, 2018[2]
Programming Language:JavaScript
Operating System:Cross-platform
Platform:See Browser support
Genre:JavaScript library, animation
License:MIT[3]

Velocity is a cross-platform JavaScript library designed to simplify the client-side scripting of website animation.[4] Velocity is free, open-source software licensed under the MIT License.[3] It is the most popular open source web animation engine.[5]

Velocity's syntax is designed to make it easier to create complex animations for HTML and SVG elements.[6] In addition to its workflow benefits, Velocity provides animation performance that is competitive with CSS-based animation.[7] Velocity achieves its performance by maintaining an internal cache of animation states and minimizing "layout thrashing," the undesirable behavior that web browsers undergo when visually updating at a fast rate.[7] Altogether, its workflow and performance benefits allow Velocity to be used for sophisticated animation programming that can be integrated into both web and mobile applications.[8] Its broad browser and device support make it ideal for large enterprise distributions that must support low-powered devices.[9]

Velocity is used to power the user interfaces of many notable websites, including Uber, Samsung, WhatsApp, Tumblr, HTC, Mazda, and Microsoft Windows. It is one of the most favorited projects on the code hosting service GitHub.[10] In 2015, Velocity was nominated for Open Source Project of the Year by The Net Awards.[11]

Features

Velocity's features include:[4]

Browser support

Velocity supports all major desktop browsers (Firefox, Google Chrome, and Safari) plus the iOS and Android mobile operating systems. Its support extends as far back as Internet Explorer 8 and Android 2.3.[15]

Usage

Including the library

The Velocity library is a single JavaScript file containing all of its core functions. It can be included within a web page by linking to a local copy or to one of the many copies available from public servers, including MaxCDN's jsDelivr or Cloudflare's cdnjs.

It is also possible to include Velocity directly from content delivery networks. (The integrity attribute is used for Subresource Integrity.)It is recommended to always use HTTPS for resources but this can be replaced with // to make use of protocol relative URLs.

Usage styles

Velocity has two usage styles:

Animation calls in Velocity consist of supplying the desired element(s) to animate, an animation property map to specify the CSS properties to be animated, and an optional options object to specify animation settings (e.g. duration).

Arguments

Velocity accepts one or more arguments. The first argument, which is required, can either be the name of a predefined Velocity command (e.g. scroll or reverse) or an object consisting of CSS properties to be animated:

// Animate an element's width to 100px and its left property to 200px$element.velocity;

The second argument, which is optional, is an object. It is used to specify animation options such as duration, easing, and complete (an arbitrary function to execute once the animation has completed):

// Animate an element's width to 100px over a 1000ms duration after pausing for a 100s delay.$element.velocity;

Chaining

Creating a series of consecutive animation calls in Velocity consists of placing velocity calls back-to-back on the target jQuery element object:

$element .velocity // Continue on to this animation once the previous one has completed .velocity // And once more... .velocity;

Scrolling and reversal

Scrolling in Velocity consists of passing in "scroll" as Velocity's first argument — in place of the typical CSS properties map:

// Scroll with a duration of 750 ms$element.velocity("scroll",);

The browser will subsequently scroll down to the top edge of the element that Velocity was invoked on.

Animation reversal in Velocity consists of passing in "reverse" as Velocity's first argument:

// Animate an element's height$element.velocity;// Reverse the previous animation; animate back to the element's original height using the previous duration$element.velocity("reverse");

Velocity's reverse command defaults to the animation options used in the prior call. Passing in a new options object extends the previous one:

$element.velocity;// Extend the previous reverse call's options object with a new duration value$element.velocity("reverse",);

History

Velocity was developed by Julian Shapiro to address a lack of performant and designer-oriented JavaScript animation libraries.[16] [17] Stripe, a popular web developer-focused Internet technology company sponsored Shapiro on a grant to help provide the financial resources necessary to continue full-time development on Velocity.[18]

The high performance of Velocity's internal animation engine helped to repopularize JavaScript-based web animation, which had previously fallen out of favor for CSS-based animation due to its speed advantages over older JavaScript libraries that lacked a focus on animation.[19]

In September 2014, Shapiro released Velocity Motion Designer, a tool for designing animations on live production websites that allowed for real-time exporting of the generated animation code for subsequent use within an IDE.[20] In March 2015, Peachpit published Shapiro's Web Animation using JavaScript book, which teaches both the beginning and advanced principles of developing web animations using Velocity. As of mid-2015, Velocity continues to be developed and maintained exclusively by Shapiro.[21]

In addition to Velocity's use in professional enterprise environments, it is also widely used for web development experimentation and beginner practicing. Proof-of-concept web development projects built on top of Velocity are commonly posted to CodePen (example), a leading community code sharing service.

See also

Further reading

External links

Notes and References

  1. Web site: julianshapiro . velocity/README.md at master · julianshapiro/velocity · GitHub . Github.com . 2021-02-13.
  2. Web site: History for package.json - julianshapiro/velocity · GitHub . Github.com . 2021-02-13.
  3. Web site: julianshapiro . velocity/LICENSE.md at master · julianshapiro/velocity · GitHub . Github.com . 2014-10-09 . 2016-01-20.
  4. Web site: JavaScript Animation. 15 June 2015.
  5. Web site: Major Contributor To Open Source Technologies, Julian Shapiro, Pulls Back the Curtains on SAAS Usage . Forbes.com . 2016-01-20.
  6. Web site: Velocity.js for designers . Studio Wolf . 2016-01-20.
  7. Web site: CSS vs. JS Animation: Which is Faster?. 28 April 2014.
  8. Web site: Velocity, the Powerhouse of JavaScript Libraries. 11 October 2017.
  9. Web site: Julian Shapiro . Incredibly Fast UI Animation Using Velocity.js . Sitepoint.com . 2014-06-16 . 2016-01-20.
  10. Web site: Search · stars:>1 · GitHub . Github.com . 2016-01-20.
  11. Web site: Shortlist The Net Awards 2015 Celebrating the best in web design and development . Thenetawards.com . 2016-01-20.
  12. Web site: Animating Without jQuery – Smashing Magazine . Smashingmagazine.com . 2014-09-04 . 2016-01-20.
  13. Web site: The Simple Intro to SVG Animation. 31 July 2014.
  14. Web site: Use Velocity.js to apply slick app-like motion effects | JavaScript | Web Designer . Webdesignermag.co.uk . 2015-01-21 . 2016-01-20.
  15. Web site: Velocity.js . Julian.com . 2016-01-20.
  16. Web site: Team . Awwwards . Interview with Julian Shapiro . Awwwards.com . 2016-01-20.
  17. Web site: Shapiro . Julian . Treat Open Source Like a Startup ★ Mozilla Hacks – the Web developer blog . Hacks.mozilla.org . 2014-05-21 . 2016-01-20.
  18. Web site: Greg Brockman . Open-Source Retreat grantees . Stripe.com . 2014-06-06 . 2016-01-20.
  19. Web site: Aurelio De Rosa . Easily Improving jQuery Animations . Sitepoint.com . 2014-06-23 . 2016-01-20.
  20. Web site: Remix this video . Velocity Motion Designer: Overview . YouTube . 2014-09-06 . 2016-01-20.
  21. Web site: Contributors to julianshapiro/Velocity. .