1.0.0 • Published 6 years ago

ilmiopacchetto v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
6 years ago

#jsAnimator

##Element

An element represent the entity to animate. It is a javascript object that must have a specific structure to be able to be animated, in particular the library expect to find three functions, but not all are mandatory. Among methods that an element can define there are:

  • fn_draw: specify how an element must be draw, for example its shape

  • fn_update: specify how an element has to update its animation, for example its position in the window

  • fn_stop: specify when the element has to stop its animation, for example when its size reach a specific dimension. This is the only function that have to return a value true if the stop condition is reached false otherwise.

as you may expect the only mandatory function is fn_draw otherwise anything will be displayed, the others can be omitted.

Library public functions

  • Add and element to be animated in the queue of jsAnimator
jsAniamtor.add(element)
  • Specify the function that will be executed anytime the render process start (before any frame render process)
jsAniamtor.setGlobalOnFrameRenderStart(function)
  • Specify a function that will be execute anytime the render process end (after any frame render process)
jsAnimator.setGlobalOnFrameRenderEnd(function)
  • Start queued animations
jsAnimator.animationStart()
  • Stop queued animations
jsAnimator.animationStop()
  • Toggle animation (pause/start)
jsAnimator.animationToggle()
  • Render the n next frame
jsAnimator.renderNext(n)

##Tip jsAnimator can handle both canvas and css animation... inside canvas, when possible, make use of caching. Caching is not directly managed by library but it is easy to implement. See example section below.

##Example

For a complete and comprehensive list of example visit jsAminator GitHub page