From 27f591474eebff99a156b9fc89cb9b344d518235 Mon Sep 17 00:00:00 2001 From: Koen Bok Date: Sat, 16 Feb 2013 15:11:28 -0800 Subject: [PATCH] Adding Animation.reverse() --- build/framer.js | 27 ++++++++++++++++++++++++--- src/animation.coffee | 14 ++++++++++---- template/framer.js | 27 ++++++++++++++++++++++++--- 3 files changed, 58 insertions(+), 10 deletions(-) diff --git a/build/framer.js b/build/framer.js index 3187d781d..90071a9c9 100644 --- a/build/framer.js +++ b/build/framer.js @@ -974,6 +974,17 @@ require.define("/src/views/view.coffee",function(require,module,exports,__dirnam } }); + View.define("rotateX", { + get: function() { + return this._rotateX || 0; + }, + set: function(value) { + this._rotateX = value; + this.style["opacity"] = value; + return this.emit("change:opacity"); + } + }); + View.prototype.removeFromSuperview = function() { return this.superView = null; }; @@ -2949,6 +2960,7 @@ require.define("/src/animation.coffee",function(require,module,exports,__dirname } this.modifiers = args.modifiers || {}; this.endProperties = args.properties; + this.originalProperties = this.view.properties; } Animation.prototype.start = function(callback) { @@ -3052,9 +3064,18 @@ require.define("/src/animation.coffee",function(require,module,exports,__dirname return _results; }; - Animation.prototype.pause = function() {}; - - Animation.prototype.revert = function() {}; + Animation.prototype.reverse = function() { + var options, p, _i, _len; + options = { + view: this.view, + properties: this.originalProperties + }; + for (_i = 0, _len = PROPERTIES.length; _i < _len; _i++) { + p = PROPERTIES[_i]; + options[p] = this[p]; + } + return new Animation(options); + }; return Animation; diff --git a/src/animation.coffee b/src/animation.coffee index cceb83f0d..96da957d0 100644 --- a/src/animation.coffee +++ b/src/animation.coffee @@ -28,6 +28,7 @@ class exports.Animation extends EventEmitter @modifiers = args.modifiers or {} @endProperties = args.properties + @originalProperties = @view.properties start: (callback) => @@ -142,8 +143,13 @@ class exports.Animation extends EventEmitter for k, v of properties if k in ["rotation", "opacity", "scale", "x", "y", "z", "width", "height"] @view[k] = properties[k] - - - pause: -> - revert: -> \ No newline at end of file + reverse: -> + options = + view: @view + properties: @originalProperties + + for p in PROPERTIES + options[p] = @[p] + + return new Animation options \ No newline at end of file diff --git a/template/framer.js b/template/framer.js index 3187d781d..90071a9c9 100644 --- a/template/framer.js +++ b/template/framer.js @@ -974,6 +974,17 @@ require.define("/src/views/view.coffee",function(require,module,exports,__dirnam } }); + View.define("rotateX", { + get: function() { + return this._rotateX || 0; + }, + set: function(value) { + this._rotateX = value; + this.style["opacity"] = value; + return this.emit("change:opacity"); + } + }); + View.prototype.removeFromSuperview = function() { return this.superView = null; }; @@ -2949,6 +2960,7 @@ require.define("/src/animation.coffee",function(require,module,exports,__dirname } this.modifiers = args.modifiers || {}; this.endProperties = args.properties; + this.originalProperties = this.view.properties; } Animation.prototype.start = function(callback) { @@ -3052,9 +3064,18 @@ require.define("/src/animation.coffee",function(require,module,exports,__dirname return _results; }; - Animation.prototype.pause = function() {}; - - Animation.prototype.revert = function() {}; + Animation.prototype.reverse = function() { + var options, p, _i, _len; + options = { + view: this.view, + properties: this.originalProperties + }; + for (_i = 0, _len = PROPERTIES.length; _i < _len; _i++) { + p = PROPERTIES[_i]; + options[p] = this[p]; + } + return new Animation(options); + }; return Animation;