Permalink
Browse files

Fixed small bug where views stayed animating

  • Loading branch information...
koenbok committed Jan 3, 2013
1 parent bb1d239 commit f9753056d596acf39761a938a081834dcf40bd76
Showing with 14 additions and 5 deletions.
  1. +2 −0 build/framer.js
  2. +7 −4 src/animation.coffee
  3. +1 −0 src/primitives/spring.coffee
  4. +2 −1 src/views/view.coffee
  5. +2 −0 template/framer.js
@@ -1568,10 +1568,12 @@ require.define("/animation.coffee",function(require,module,exports,__dirname,__f
Animation.prototype.stop = function() {
this._stop = true;
this._end();
return this.view.style.webkitTransform = this.view.computedStyle.webkitTransform;
};
Animation.prototype._end = function(callback) {
this.view._animationDuration = 0;
this.emit("end", this);
utils.remove(this.view._animations, this);
return typeof callback === "function" ? callback() : void 0;
@@ -3,7 +3,7 @@
require "./utils"
PROPERTIES = ["view", "curve", "time", "origin"]
PROPERTIES = ["view", "curve", "time", "origin", "tolerance"]
parseCurve = (a) ->
@@ -45,6 +45,8 @@ class exports.Animation extends EventEmitter
# console.log "Animation.stop", @
_end: (callback) =>
# @view._animated = false
@view._animationDuration = 0
@emit "end", @
utils.remove @view._animations, @
callback?()
@@ -74,6 +76,7 @@ class exports.Animation extends EventEmitter
friction: values[1]
velocity: values[2]
speed: 1/60
tolerance: @tolerance or 0.01
@_startSpring options, callback
@@ -102,9 +105,6 @@ class exports.Animation extends EventEmitter
value = @spring.next()
if @modifiers[k]
value = @modifiers[k](value)
nextState = {}
for k, v of beginState
@@ -116,6 +116,9 @@ class exports.Animation extends EventEmitter
# for designers, but you lose some control wit this magic added.
# if k in ["x", "y", "z", "width", "height"]
# nextState[k] = parseInt nextState[k]
if @modifiers[k]
nextState[k] = @modifiers[k](nextState[k])
@_animate nextState, "linear", @spring.speed, run
@@ -90,6 +90,7 @@ class Spring
# See if we reached the end state
netValueIsLow = Math.abs(netFloat) < @tolerance
netVelocityIsLow = Math.abs(net1DVelocity) < @tolerance
stopSpring = netValueIsLow and netVelocityIsLow
@moving = !stopSpring
@@ -203,6 +203,7 @@ class View extends Frame
# @addClass "animated" if value is true
# @removeClass "animated" if value is false
@__animated = value
# Small hack to go to next event tick and make sure
@@ -248,7 +249,7 @@ class View extends Frame
@define "style"
get: -> @_element.style
set: (value) ->
set: (value) ->
utils.extend @_element.style, value
@emit "change:style"
@@ -1568,10 +1568,12 @@ require.define("/animation.coffee",function(require,module,exports,__dirname,__f
Animation.prototype.stop = function() {
this._stop = true;
this._end();
return this.view.style.webkitTransform = this.view.computedStyle.webkitTransform;
};
Animation.prototype._end = function(callback) {
this.view._animationDuration = 0;
this.emit("end", this);
utils.remove(this.view._animations, this);
return typeof callback === "function" ? callback() : void 0;

0 comments on commit f975305

Please sign in to comment.