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

@proyecto26/animatable-component

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@proyecto26/animatable-component

A WebComponent to use Web Animations API in a declarative way! 💅

  • 0.0.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1K
increased by40.35%
Maintainers
1
Weekly downloads
 
Created
Source

Built With Stencil

Animatable Component

Web Component built with Stencil.js to use Web Animations API in a declarative way.

<animatable-component
  autoPlay
  easing='ease-in-out'
  duration={800}
  delay={300}
  keyFrames={[
    {
      opacity: '0',
      transform: 'rotate(0deg)'
    },
    {
      opacity: '1',
      transform: 'rotate(360deg)'
    }
  ]}
  onFinish={() => alert('Eureka!')}
>
  <h1>Hello World</h1>
</animatable-component>

To animate things you can use the createAnimatableComponent utility:

const SendMessageButton = (props) =>(
  <ion-fab-button {...props}>
    <ion-icon name='send' />
  </ion-fab-button>
)
const AnimatableSendMessageButton = createAnimatableComponent(SendMessageButton)


const keyFramesSendMessage: Keyframe[] = [
  {
    opacity: '0',
    transform: 'rotate(0deg)'
  },
  {
    opacity: '1',
    transform: 'rotate(360deg)'
  }
]

const optionsSendMessage: KeyframeAnimationOptions = {
  duration: 500,
  easing: 'ease-in-out'
}

...
  render() {
    return (
       <AnimatableSendMessageButton
        keyFrames={keyFramesSendMessage}
        options={optionsSendMessage}
        onClick={() => alert('Eureka!')}
      />
    )
  }
...

Properties

PropertyAttributeDescriptionTypeDefault
animateIdanimate-idA DOMString with which to reference the animation.stringundefined
autoPlayauto-playStart the animation when the component is mounted.booleantrue
compositecompositeDetermines how values are combined between this animation and other, separate animations that do not specify their own specific composite operation. Defaults to replace."accumulate" | "add" | "replace"undefined
currentTimecurrent-timeSets the current time value of the animation in milliseconds, whether running or paused.numberundefined
delaydelayThe number of milliseconds to delay the start of the animation. Defaults to 0.numberundefined
directiondirectionDirection of the animation."alternate" | "alternate-reverse" | "normal" | "reverse"undefined
durationdurationThe number of milliseconds each iteration of the animation takes to complete. Defaults to 0.numberundefined
easingeasingThe rate of the animation's change over time.stringundefined
endDelayend-delayThe number of milliseconds to delay after the end of an animation.numberundefined
fillfillDictates whether the animation's effects should be reflected by the element(s) prior to playing ("backwards"), retained after the animation has completed playing ("forwards"), or both. Defaults to "none"."auto" | "backwards" | "both" | "forwards" | "none"undefined
iterationCompositeiteration-compositeDetermines how values build from iteration to iteration in this animation."accumulate" | "replace"undefined
iterationStartiteration-startDescribes at what point in the iteration the animation should start.numberundefined
iterationsiterationsThe number of times the animation should repeat. Defaults to 1, and can also take a value of Infinity to make it repeat for as long as the element exists.numberundefined
keyFrames--Keyframes of the animation.Keyframe[]undefined
keyFramesDatakey-frames-dataKeyframes of the animation in string format.stringundefined
options--Default options of the animation.KeyframeAnimationOptionsundefined
optionsDataoptions-dataDefault options of the animation in string format.stringundefined
playbackRateplayback-rateSets the playback rate of the animation.numberundefined
startTimestart-timeSets the scheduled time when an animation's playback should begin.numberundefined

Events

EventDescriptionType
cancelThis event is sent when the animation is cancelled.CustomEvent<HTMLElement>
finishThis event is sent when the animation finishes playing.CustomEvent<HTMLElement>

Methods

cancel() => Promise<void>

Clears all KeyframeEffects caused by this animation and aborts its playback.

Returns

Type: Promise<void>

finish() => Promise<void>

Sets the current playback time to the end of the animation corresponding to the current playback direction.

Returns

Type: Promise<void>

getCurrentTime() => Promise<number>

Returns the current time value of the animation in milliseconds, whether running or paused.

Returns

Type: Promise<number>

getPending() => Promise<boolean>

Indicates whether the animation is currently waiting for an asynchronous operation such as initiating playback or pausing a running animation.

Returns

Type: Promise<boolean>

getPlayState() => Promise<AnimationPlayState>

Returns an enumerated value describing the playback state of an animation.

Returns

Type: Promise<AnimationPlayState>

getPlaybackRate() => Promise<number>

Returns the playback rate of the animation.

Returns

Type: Promise<number>

getStartTime() => Promise<number>

Returns the scheduled time when an animation's playback should begin.

Returns

Type: Promise<number>

pause() => Promise<void>

Suspends playback of the animation.

Returns

Type: Promise<void>

play() => Promise<void>

Starts or resumes playing of an animation.

Returns

Type: Promise<void>

reverse() => Promise<void>

Reverses the playback direction, meaning the animation ends at its beginning.

Returns

Type: Promise<void>

Using this component

Script tag

  • Put a script tag similar to this <script src='https://unpkg.com/animatable-component@0.0.1/dist/animatable-component.js'></script> in the head of your index.html
  • Then you can use the element anywhere in your template, JSX, html etc

Node Modules

  • Run npm install @proyecto26/animatable-component --save
  • Put a script tag similar to this <script src='node_modules/@proyecto26/animatable-component/dist/animatable-component.js'></script> in the head of your index.html
  • Then you can use the element anywhere in your template, JSX, html etc

In a stencil-starter app

  • Run npm install @proyecto26/animatable-component --save
  • Add an import to the npm packages import @proyecto26/animatable-component;
  • Then you can use the element anywhere in your template, JSX, html etc

Supporting 🍻

I believe in Unicorns 🦄 Support me, if you do too.

Security contact information 🚨

To report a security vulnerability, please use the Tidelift security contact. Tidelift will coordinate the fix and disclosure.

Happy coding 💯

Made with ❤️

FAQs

Package last updated on 28 Oct 2019

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