Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@hookun/parse-animation-shorthand

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hookun/parse-animation-shorthand

A parser for the value of CSS animation shorthand property.

  • 0.1.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.3K
decreased by-9.25%
Maintainers
1
Weekly downloads
 
Created
Source

@hookun/parse-animation-shorthand

codecov Test

A parser for The animation shorthand CSS property.

Install

npm install @hookun/parse-animation-shorthand

API

parse(value: string) → Array<CSSAnimation>

import {parse} from '@hookun/parse-animation-shorthand';
const result = parse('3s ease-in SlideIn, .2s .1s ease FadeIn');
const expectedResult = [
    {
        name: 'SlideIn',
        duration: 3000,
        delay: 'unset',
        timingFunction: 'ease-in',
        iterationCount: 'unset',
        direction: 'unset',
        fillMode: 'unset',
        playState: 'unset',
    },
    {
        name: 'FadeIn',
        duration: 200,
        delay: 100,
        timingFunction: 'ease',
        iterationCount: 'unset',
        direction: 'unset',
        fillMode: 'forwards',
        playState: 'unset',
    },
];

serialize(value: CSSAnimation) → string

import {serialize} from '@hookun/parse-animation-shorthand';
const result = serialize({
    name: 'SlideIn',
    duration: 3000,
    delay: 'unset',
    timingFunction: 'ease-in',
    iterationCount: 'unset',
    direction: 'unset',
    fillMode: 'unset',
    playState: 'unset',
});
const expectedResult = '3s ease-in SlideIn';

What's the CSSAnimation?

interface CSSAnimation {
    name: string
    duration: number | Unset
    timingFunction: CSSTimingFunction | Unset
    delay: number | Unset
    iterationCount: number | 'infinite' | Unset
    direction: CSSAnimationDirection | Unset
    fillMode: CSSAnimationFillMode | Unset
    playState: CSSAnimationPlayState | Unset
}

type Unset = 'unset'

type CSSTimingFunction =
| CSSTimingFunctionKeyword
| CSSCubicBezier
| CSSSteps

type CSSTimingFunctionKeyword =
| 'ease'
| 'ease-in'
| 'ease-out'
| 'ease-in-out'
| 'linear'
| 'step-start'
| 'step-end'

interface CSSCubicBezier {
    type: 'cubic-bezier'
    value: [number, number, number, number]
}

interface CSSSteps {
    type: 'steps'
    stepCount: number
    direction: CSSStepDirection
}

type CSSStepDirection =
| 'jump-start'
| 'jump-end'
| 'jump-none'
| 'jump-both'
| 'start'
| 'end'

type CSSAnimationDirection =
| 'normal'
| 'reverse'
| 'alternate'
| 'alternate-reverse';

type CSSAnimationFillMode =
| 'none'
| 'forwards'
| 'backwards'
| 'both'

type CSSAnimationPlayState =
| 'paused'
| 'running'

License

Apache License, Version 2.0

FAQs

Package last updated on 06 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc