Skip to content
Permalink
Browse files

Fix animation bug and add unit tests again.

  • Loading branch information...
Koen Bok
Koen Bok committed May 24, 2013
1 parent 2322236 commit 150f96970afcd03e4aadf40b8f60fb27cfb5e559
Showing with 30 additions and 33 deletions.
  1. +19 −27 build/framer.js
  2. +7 −5 src/animation.coffee
  3. +3 −0 test/index.html
  4. +1 −1 test/init.coffee
@@ -1,7 +1,7 @@
// Framer 2.0 (c) 2013 Koen Bok
// Framer 2.0-12-g2322236 (c) 2013 Koen Bok
// https://github.com/koenbok/Framer

window.FramerVersion = "2.0";
window.FramerVersion = "2.0-12-g2322236";


(function(){var require = function (file, cwd) {
@@ -2588,7 +2588,7 @@ require.define("/src/views/view.coffee",function(require,module,exports,__dirnam
throw Error("View._matrix.set should be Matrix not " + (typeof matrix));
}
this.__matrix = matrix;
return this.style.webkitTransform = this.__matrix.matrix().cssValues();
return this.style.webkitTransform = this.__matrix.css();
}
});

@@ -3678,15 +3678,13 @@ require.define("/src/eventemitter.coffee",function(require,module,exports,__dirn
});

require.define("/src/primitives/matrix.coffee",function(require,module,exports,__dirname,__filename,process,global){(function() {
var Matrix, utils, _;
var EmptyMatrix, Matrix, utils, _;

_ = require("underscore");

utils = require("../utils");

WebKitCSSMatrix.prototype.cssValues = function() {
return this.toString();
};
EmptyMatrix = new WebKitCSSMatrix();

Matrix = (function() {
function Matrix(matrix) {
@@ -3830,18 +3828,18 @@ require.define("/src/primitives/matrix.coffee",function(require,module,exports,_
return this.rotationZ = v.rotation.z / Math.PI * 180;
};

Matrix.prototype.matrix = function() {
Matrix.prototype.set = function(view) {
return view._matrix = this;
};

Matrix.prototype.css = function() {
var m;

m = new WebKitCSSMatrix();
m = EmptyMatrix;
m = m.translate(this._x, this._y, this._z);
m = m.rotate(this._rotationX, this._rotationY, this._rotationZ);
m = m.scale(this.scaleX, this.scaleY, this.scaleZ);
return m;
};

Matrix.prototype.set = function(view) {
return view._matrix = this;
m = m.scale(this._scaleX, this._scaleY, this._scaleZ);
return m.toString();
};

return Matrix;
@@ -4009,10 +4007,10 @@ require.define("/src/animation.coffee",function(require,module,exports,__dirname
}
animatedProperties = [];
for (k in this.propertiesA) {
if (this.debug) {
console.log(" ." + k + " " + this.propertiesA[k] + " -> " + this.propertiesB[k]);
}
if (this.propertiesA[k] !== this.propertiesB[k]) {
if (this.debug) {
console.log(" ." + k + " " + this.propertiesA[k] + " -> " + this.propertiesB[k]);
}
animatedProperties.push(k);
}
}
@@ -4029,7 +4027,7 @@ require.define("/src/animation.coffee",function(require,module,exports,__dirname
if (__indexOf.call(animatedProperties, "rotationX") >= 0 || __indexOf.call(animatedProperties, "rotationY") >= 0) {
backsideVisibility = "visible";
}
css.addStyle(" " + this.keyFrameAnimationCSS + " ." + this.animationName + " { -webkit-animation-duration: " + (this.totalTime / 1000) + "s; -webkit-animation-name: " + this.animationName + "; -webkit-animation-timing-function: linear; -webkit-animation-fill-mode: both; -webkit-tranform-origin: " + this.origin + "; -webkit-backface-visibility: " + backsideVisibility + "; }");
css.addStyle(" " + this.keyFrameAnimationCSS + " ." + this.animationName + " { -webkit-animation-duration: " + (this.totalTime / 1000) + "s; -webkit-animation-name: " + this.animationName + "; -webkit-animation-timing-function: linear; -webkit-animation-fill-mode: both; -webkit-transform-origin: " + this.origin + "; -webkit-backface-visibility: " + backsideVisibility + "; }");
this.view.addClass(this.animationName);
this.view.once("webkitAnimationStart", function(event) {
var endTime;
@@ -4066,20 +4064,14 @@ require.define("/src/animation.coffee",function(require,module,exports,__dirname

Animation.prototype.stop = function() {
if (this.debug) {
console.log("Animation[" + this.animationId + "].stop " + this.animationName);
return console.log("Animation[" + this.animationId + "].stop " + this.animationName);
}
this._canceled = true;
return this._cleanup(false);
};

Animation.prototype._finalize = function() {
if (this._canceled === true) {
return;
}
if (this.debug) {
console.log("Animation[" + this.animationId + "].end " + this.animationName);
}
this._cleanup(true);
return typeof callback === "function" ? callback() : void 0;
};

@@ -4155,7 +4147,7 @@ require.define("/src/animation.coffee",function(require,module,exports,__dirname
matrix[propertyName] = this.view[propertyName];
}
}
cssString.push(matrix.matrix().cssValues() + "; ");
cssString.push(matrix.css() + "; ");
_ref1 = this.AnimatableCSSProperties;
for (propertyName in _ref1) {
unit = _ref1[propertyName];
@@ -155,8 +155,8 @@ class Animation extends EventEmitter
animatedProperties = []

for k of @propertiesA
console.log " .#{k} #{@propertiesA[k]} -> #{@propertiesB[k]}" if @debug
if @propertiesA[k] isnt @propertiesB[k]
console.log " .#{k} #{@propertiesA[k]} -> #{@propertiesB[k]}" if @debug
animatedProperties.push k

# Throw a warning if we have nothing to animate
@@ -229,20 +229,22 @@ class Animation extends EventEmitter
stop: =>

console.log "Animation[#{@animationId}].stop #{@animationName}" if @debug
@_canceled = true

@_cleanup false

# @view.style["-webkit-animation-play-state"] = "paused"
# @view.style["-webkit-animation-play-state"] = "running"


_finalize: =>

if @_canceled is true
return
# if @_canceled is true
# return

console.log "Animation[#{@animationId}].end #{@animationName}" if @debug

@_cleanup true

callback?()


@@ -17,7 +17,10 @@

<script>
chai.should()
mocha.setup('bdd')
mocha.setup({globals: ["_delayTmers"]});
$(function() {
if (window.mochaPhantomJS) {
mochaPhantomJS.run();
@@ -1,4 +1,4 @@
{EventTest} = require './tests/events'
{DebugTest} = require './tests/debug'
{ViewTest} = require './tests/view'
# {AnimationTest} = require './tests/animation'
{AnimationTest} = require './tests/animation'

0 comments on commit 150f969

Please sign in to comment.
You can’t perform that action at this time.