npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

css-animated-properties

v1.1.1

Published

A simple list of which CSS properties can be animated and how

Downloads

17

Readme

CSS Animated Properties

A simple way to list which CSS properties can be animated and how, as defined in various W3C specs.

I needed something like this for a project and hand-rolled some basic data. But it might be useful for other people too, so I pulled out the data, cleaned it up and added some convenience methods.

Enjoy.

Caveats & Citations

Only specs that are Candidate Recommendations or better are counted, with the exception of some Working Drafts that have a lot of traction in browser implementations. So far the WD specs included here are Text Level 3, Flexbox and Transforms.

If a property is not in this list, it's not able to be consistently animated. Technically background-image can be animated in some ways, but against the spec (which says it can’t be animated at all).

For better details about individual browser support, see http://thewebevolved.com/support/animation/properties/. There is also a great amount of detail at http://oli.jp/2010/css-animatable-properties/, but I needed something that was usable by scripts.

Usage

Available on npm as css-animated-properties, or in the browser as a global called cssAnimProps

Properties

animatedProperties

The core data as a simple JS object. Each key is a CSS property. If a property isn’t in the list, it’s not animateable via CSS.

There are convenience methods (listed below) that mean you shouldn’t need to access this list directly, but it’s available for other use cases.

types

The types of values that can be animated. Each key is a value type that is referenced in the animatedProperties list. Each type contains properties of name (display name) and href (link to the W3C spec where the value type is defined).

For quick reference, most of the types are defined at https://www.w3.org/TR/css3-transitions/.

Methods

canAnimate()

  • Takes a CSS property and returns whether that property can be animated by CSS.
  • Parameters: property (String)
  • Returns: Boolean
cssAnimProps.canAnimate('margin');    // true
cssAnimProps.canAnimate('position');  // false

getProperty()

  • Takes a CSS property and returns the definition of how it can be animated. For properties that are shorthand combinations of other properties (e.g. border) this definition can be recursive.
  • Parameters: property (String), expand (Boolean – optional, default false)
  • Returns: Object with a combination of the following properties (all are optional), or null if property can’t be animated.
    • properties (Array) – A list of other CSS properties that make up this property’s definition. The values of the array depend on the expand parameter.
    • types (Array) – A list of one or more types of value – these refer to keys in the types property. Only one of types and properties will be present on the same object.
    • multiple (Boolean) – If true, multiple space-separated values can be present (e.g. transform-origin).
    • repeatable (Boolean) – If true, multiple comma-separated sets of values can be present (e.g. background-position).
cssAnimProps.getProperty('color');
// {name: 'color', types: ['color']}

cssAnimProps.getProperty('position');
// null

cssAnimProps.getProperty('transform-origin');
// {name: 'transform-origin', types: ['length-percentage-calc'], multiple: true}

cssAnimProps.getProperty('border-color');
/*
{
    name: 'border-color',
    properties: [
        'border-top-color',
        'border-right-color',
        'border-bottom-color',
        'border-left-color'
    ]
}
*/

cssAnimProps.getProperty('border-color', true);
/*
{
    name: 'border-color',
    properties: [
        {name: 'border-top-color', types: ['color']},
        {name: 'border-right-color', types: ['color']},
        {name: 'border-bottom-color', types: ['color']},
        {name: 'border-left-color', types: ['color']}
    ]
}
*/

Licence

MIT