From 4686f4fcd68e9eead26a3fd679c6796c174ad707 Mon Sep 17 00:00:00 2001 From: Koen Bok Date: Thu, 25 Sep 2014 15:31:20 +0200 Subject: [PATCH] Fix animation events add querySelector --- framer/Animation.coffee | 18 ++++-------------- framer/Animator.coffee | 4 +--- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/framer/Animation.coffee b/framer/Animation.coffee index 3649c6b44..bb2c5b26d 100644 --- a/framer/Animation.coffee +++ b/framer/Animation.coffee @@ -109,17 +109,11 @@ class exports.Animation extends EventEmitter console.log "Animation.start" console.log "\t#{k}: #{@_stateA[k]} -> #{@_stateB[k]}" for k, v of @_stateB - # TODO - - @_animator.on "start", => @emit "start" - @_animator.on "stop", => @emit "stop" - @_animator.on "end", => @emit "end" - # See if we need to repeat this animation # Todo: more repeat behaviours: # 1) add (from end position) 2) reverse (loop between a and b) if @_repeatCounter > 0 - @_animator.on "end", => + @on "end", => for k, v of @_stateA @_target[k] = v @_repeatCounter-- @@ -131,13 +125,8 @@ class exports.Animation extends EventEmitter else @_start() - - - - - stop: -> - @_animator.emit("stop") + @emit("stop") Framer.Loop.off("update", @_update) # _runningAnimations = _.without _runningAnimations, @ @@ -159,12 +148,13 @@ class exports.Animation extends EventEmitter @options.layer.emit(event, @) _start: => + @emit("start") Framer.Loop.on("update", @_update) _update: (delta) => if @_animator.finished() @_updateValue(1) - @_animator.emit("end") + @emit("end") @stop() else @_updateValue(@_animator.next(delta)) diff --git a/framer/Animator.coffee b/framer/Animator.coffee index 5adecf81b..deeb22f57 100644 --- a/framer/Animator.coffee +++ b/framer/Animator.coffee @@ -1,10 +1,8 @@ Utils = require "./Utils" {Config} = require "./Config" -{EventEmitter} = require "./EventEmitter" -{AnimationLoop} = require "./AnimationLoop" -class exports.Animator extends EventEmitter +class exports.Animator """ The animator class is a very simple class that