Permalink
Browse files

Fixed bug where new views did not have x, y, width, height values if …

…not set
  • Loading branch information...
koenbok committed Oct 15, 2013
1 parent 6c102c2 commit 4a289c595f02950b7cc8cf9784d3ce4bd0ed99c3
Showing with 72 additions and 25 deletions.
  1. +28 −12 build/framer.js
  2. +7 −1 src/views/view.coffee
  3. +28 −12 template/framer.js
  4. +9 −0 test/tests/view.coffee
@@ -1,7 +1,7 @@
// Framer 2.0-33-g3e4051b (c) 2013 Koen Bok
// Framer 2.0-38-g6c102c2 (c) 2013 Koen Bok
// https://github.com/koenbok/Framer
window.FramerVersion = "2.0-33-g3e4051b";
window.FramerVersion = "2.0-38-g6c102c2";
(function(){var require = function (file, cwd) {
@@ -567,6 +567,18 @@ require.define("/src/utils.coffee",function(require,module,exports,__dirname,__f
return Math.round(value * d) / d;
};
exports.defaults = function(obj, defaults) {
var k, result, v, _ref;
result = _.extend(obj);
for (k in defaults) {
v = defaults[k];
if ((_ref = result[k]) === null || _ref === (void 0)) {
result[k] = defaults[k];
}
}
return result;
};
exports.randomColor = function(alpha) {
var c;
if (alpha == null) {
@@ -2391,19 +2403,28 @@ require.define("/src/views/view.coffee",function(require,module,exports,__dirnam
return p;
},
set: function(args) {
var key, value, _ref, _ref1, _ref2, _ref3, _results;
var key, value, _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _results;
_ref = View.Properties;
for (key in _ref) {
value = _ref[key];
if ((_ref1 = args[key]) !== null && _ref1 !== (void 0)) {
this[key] = args[key];
}
}
_ref2 = Frame.CalculatedProperties;
_results = [];
_ref2 = Frame.Properties;
for (key in _ref2) {
value = _ref2[key];
if ((_ref3 = args[key]) !== null && _ref3 !== (void 0)) {
this[key] = args[key];
} else {
this[key] = Frame.Properties[key];
}
}
_ref4 = Frame.CalculatedProperties;
_results = [];
for (key in _ref4) {
value = _ref4[key];
if ((_ref5 = args[key]) !== null && _ref5 !== (void 0)) {
_results.push(this[key] = args[key]);
} else {
_results.push(void 0);
@@ -2985,7 +3006,7 @@ require.define("/src/views/view.coffee",function(require,module,exports,__dirnam
}).call(this, Frame);
View.Properties = utils.extend(Frame.Properties, {
View.Properties = utils.extend({}, Frame.Properties, {
frame: null,
clip: true,
opacity: 1.0,
@@ -4191,7 +4212,7 @@ require.define("/src/animation.coffee",function(require,module,exports,__dirname
};
Animation.prototype._cleanup = function(completed) {
var computedStyles, cssFilterProperties, endMatrix, endStyles, i, _i, _len, _ref, _ref1, _ref2, _ref3;
var computedStyles, cssFilterProperties, endMatrix, endStyles, _ref, _ref1, _ref2;
this.view._currentAnimations = _.without(this.view._currentAnimations, this);
if (completed) {
endMatrix = utils.extend(new Matrix(), this.propertiesB);
@@ -4219,11 +4240,6 @@ require.define("/src/animation.coffee",function(require,module,exports,__dirname
v = _ref2[k];
endStyles[k] = computedStyles[k];
}
_ref3 = computedStyles.cssText.split(";");
for (_i = 0, _len = _ref3.length; _i < _len; _i++) {
i = _ref3[_i];
console.log(i);
}
endStyles.webkitFilter = computedStyles.webkitFilter;
}
this.view.removeClass(this.animationName);
@@ -69,6 +69,12 @@ class View extends Frame
if args[key] not in [null, undefined]
@[key] = args[key]
for key, value of Frame.Properties
if args[key] not in [null, undefined]
@[key] = args[key]
else
@[key] = Frame.Properties[key]
for key, value of Frame.CalculatedProperties
@[key] = args[key] if args[key] not in [null, undefined]
@@ -509,7 +515,7 @@ class View extends Frame
off: @::removeListener
View.Properties = utils.extend Frame.Properties,
View.Properties = utils.extend {}, Frame.Properties,
frame: null
clip: true
opacity: 1.0
@@ -1,7 +1,7 @@
// Framer 2.0-33-g3e4051b (c) 2013 Koen Bok
// Framer 2.0-38-g6c102c2 (c) 2013 Koen Bok
// https://github.com/koenbok/Framer
window.FramerVersion = "2.0-33-g3e4051b";
window.FramerVersion = "2.0-38-g6c102c2";
(function(){var require = function (file, cwd) {
@@ -567,6 +567,18 @@ require.define("/src/utils.coffee",function(require,module,exports,__dirname,__f
return Math.round(value * d) / d;
};
exports.defaults = function(obj, defaults) {
var k, result, v, _ref;
result = _.extend(obj);
for (k in defaults) {
v = defaults[k];
if ((_ref = result[k]) === null || _ref === (void 0)) {
result[k] = defaults[k];
}
}
return result;
};
exports.randomColor = function(alpha) {
var c;
if (alpha == null) {
@@ -2391,19 +2403,28 @@ require.define("/src/views/view.coffee",function(require,module,exports,__dirnam
return p;
},
set: function(args) {
var key, value, _ref, _ref1, _ref2, _ref3, _results;
var key, value, _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _results;
_ref = View.Properties;
for (key in _ref) {
value = _ref[key];
if ((_ref1 = args[key]) !== null && _ref1 !== (void 0)) {
this[key] = args[key];
}
}
_ref2 = Frame.CalculatedProperties;
_results = [];
_ref2 = Frame.Properties;
for (key in _ref2) {
value = _ref2[key];
if ((_ref3 = args[key]) !== null && _ref3 !== (void 0)) {
this[key] = args[key];
} else {
this[key] = Frame.Properties[key];
}
}
_ref4 = Frame.CalculatedProperties;
_results = [];
for (key in _ref4) {
value = _ref4[key];
if ((_ref5 = args[key]) !== null && _ref5 !== (void 0)) {
_results.push(this[key] = args[key]);
} else {
_results.push(void 0);
@@ -2985,7 +3006,7 @@ require.define("/src/views/view.coffee",function(require,module,exports,__dirnam
}).call(this, Frame);
View.Properties = utils.extend(Frame.Properties, {
View.Properties = utils.extend({}, Frame.Properties, {
frame: null,
clip: true,
opacity: 1.0,
@@ -4191,7 +4212,7 @@ require.define("/src/animation.coffee",function(require,module,exports,__dirname
};
Animation.prototype._cleanup = function(completed) {
var computedStyles, cssFilterProperties, endMatrix, endStyles, i, _i, _len, _ref, _ref1, _ref2, _ref3;
var computedStyles, cssFilterProperties, endMatrix, endStyles, _ref, _ref1, _ref2;
this.view._currentAnimations = _.without(this.view._currentAnimations, this);
if (completed) {
endMatrix = utils.extend(new Matrix(), this.propertiesB);
@@ -4219,11 +4240,6 @@ require.define("/src/animation.coffee",function(require,module,exports,__dirname
v = _ref2[k];
endStyles[k] = computedStyles[k];
}
_ref3 = computedStyles.cssText.split(";");
for (_i = 0, _len = _ref3.length; _i < _len; _i++) {
i = _ref3[_i];
console.log(i);
}
endStyles.webkitFilter = computedStyles.webkitFilter;
}
this.view.removeClass(this.animationName);
@@ -79,6 +79,15 @@ describe "View", ->
frameTest.y.should.equal -40
frameTest.width.should.equal 530
frameTest.height.should.equal 540
it "should have default values", ->
view = new View()
view.x.should.equal 0
view.y.should.equal 0
view.width.should.equal 0
view.height.should.equal 0
describe "Visual", ->

0 comments on commit 4a289c5

Please sign in to comment.