1.1.0 • Published 4 years ago

@twoavy/sprite-animation v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

sprite-animation

A Vue component for sprite-based animations

Installation

yarn add @twoavy/sprite-animation 
import SpriteAnimation from '@twoavy/sprite-animation'

Usage

<sprite-animation ref="anim" :width="500" :height="500" :frames="30"
                  :duration="5" :sprite="require('@/assets/sprite.png')" />

Props

NameTypeDefaultNote
widthstringrequiredframe width
heightstringrequiredframe height
framesnumberrequirednumber of frames
durationnumberrequiredduration of the animation in secs
spritestringrequiredpath to the sprite image
loopbooleantrueloop the animation (plays once otherwise)
autoplaybooleantrueautomatically start playing

Methods

play()

// start animation if autoplay is set to false
this.$refs.anim.play()

Events

  • @start - animation started
  • @loop - called on each animation iteration (if loop is set to true)
  • @end - animation ended
  • @cancel - animation was cancelled