neft
Version:
Universal Platform
127 lines (93 loc) • 3.04 kB
text/coffeescript
# Animation
'use strict'
utils = require 'src/utils'
assert = require 'src/assert'
signal = require 'src/signal'
module.exports = (Renderer, Impl, itemUtils) -> class Animation extends Renderer.Extension
= 'Animation'
## *Animation* Animation::constructor() : *Renderer.Extension*
constructor: ->
super()
= false
= false
= false
## *Signal* Animation::onStart()
signal.Emitter.createSignal @, 'onStart'
## *Signal* Animation::onStop()
signal.Emitter.createSignal @, 'onStop'
itemUtils.defineProperty
constructor: @
name: 'running'
developmentSetter: (val) ->
assert.isBoolean val
setter: (_super) -> (val) ->
= val
oldVal =
if oldVal is val
return
_super.call @, val
if val
Impl.startAnimation.call @
.emit()
if
Impl.pauseAnimation.call @
else
if
= false
Impl.stopAnimation.call @
.emit()
return
## *Boolean* Animation::paused
## *Signal* Animation::onPausedChange(*Boolean* oldValue)
itemUtils.defineProperty
constructor: @
name: 'paused'
developmentSetter: (val) ->
assert.isBoolean val
setter: (_super) -> (val) ->
oldVal =
if oldVal is val
return
_super.call @, val
if val
Impl.pauseAnimation.call @
else
Impl.resumeAnimation.call @
return
## *Boolean* Animation::reversed
## *Signal* Animation::onReversedChange(*Boolean* oldValue)
itemUtils.defineProperty
constructor: @
name: 'reversed'
implementation: Impl.setAnimationReversed
developmentSetter: (val) ->
assert.isBoolean val
## *Boolean* Animation::loop
## *Signal* Animation::onLoopChange(*Boolean* oldValue)
itemUtils.defineProperty
constructor: @
name: 'loop'
implementation: Impl.setAnimationLoop
developmentSetter: (val) ->
assert.isBoolean val
## Animation::start()
start: ->
= true
@
## Animation::stop()
stop: ->
= false
@
## Animation::pause()
pause: ->
if
= true
@
## Animation::resume()
resume: ->
= false
@
enable: ->
= true
disable: ->
= false