Skip to content

jwmerrill/elm-animation-frame

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AnimationFrame

Deprecation Notice

As of Elm 0.17, this package has been replaced with elm-lang/animation-frame, which provides an animation frame subscription in place of this package's animation frame signal.

Legacy Documentation:

This library provides time Signals that are synchronized to the monitor's frame rate, by binding javascript's requestAnimationFrame. Using AnimationFrame.frame or AnimationFrame.frameWhen instead of (Time.fps 60) or (Time.fpsWhen 60) makes it possible (but not guaranteed...) to achieve 60 fps animation without stutter in Elm.

Example Usage

import AnimationFrame
import Graphics.Element
import Signal

main = Signal.map Graphics.Element.show (Signal.foldp (+) 0 AnimationFrame.frame)

See examples/counter.elm for a minimal working example that uses both AnimationFrame.frame and AnimationFrame.frameWhen. You can see this example in action here. The top counter uses AnimationFrame.frame to count continuously. The bottom counter uses AnimationFrame.frameWhen to count only when the mouse is down.

Performance Comparison

The following simple animation demonstrates the performance difference between using core's Time.fps, and AnimationFrame.frame

About

An Elm Signal that is synchronized with the monitor's refresh rate.

Resources

License

Stars

Watchers

Forks

Packages

No packages published