Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Merge pull request #44 from jacobmesu/master
Fixed Frame.Merge should now calculate the size right
- Loading branch information
Showing
with
44 additions
and
15 deletions.
-
+7
−5
build/framer.js
-
+8
−4
src/primitives/frame.coffee
-
+7
−5
template/framer.js
-
+22
−1
test/tests/view.coffee
|
@@ -3632,13 +3632,15 @@ require.define("/src/primitives/frame.coffee",function(require,module,exports,__ |
|
|
}); |
|
|
|
|
|
Frame.prototype.merge = function(r2) { |
|
|
var frame, r1; |
|
|
var frame, r1, xmin, ymin; |
|
|
r1 = this; |
|
|
xmin = Math.min(r1.x, r2.x); |
|
|
ymin = Math.min(r1.y, r2.y); |
|
|
frame = { |
|
|
x: Math.min(r1.x, r2.x), |
|
|
y: Math.min(r1.y, r2.y), |
|
|
width: Math.max(r1.width, (r2.x - r1.x) + r2.width), |
|
|
height: Math.max(r1.height, (r2.y - r1.y) + r2.height) |
|
|
x: xmin, |
|
|
y: ymin, |
|
|
width: Math.max(r1.x + r1.width, r2.x + r2.width) - xmin, |
|
|
height: Math.max(r1.y + r1.height, r2.y + r2.height) - ymin |
|
|
}; |
|
|
return new Frame(frame); |
|
|
}; |
|
|
|
@@ -66,11 +66,15 @@ class Frame extends EventEmitter |
|
|
|
|
|
merge: (r2) -> |
|
|
r1 = @ |
|
|
|
|
|
xmin = Math.min(r1.x, r2.x) |
|
|
ymin = Math.min(r1.y, r2.y) |
|
|
|
|
|
frame = |
|
|
x: Math.min(r1.x, r2.x) |
|
|
y: Math.min(r1.y, r2.y) |
|
|
width: Math.max(r1.width, (r2.x - r1.x) + r2.width), |
|
|
height: Math.max(r1.height, (r2.y - r1.y) + r2.height) |
|
|
x: xmin |
|
|
y: ymin |
|
|
width: Math.max(r1.x + r1.width, r2.x + r2.width) - xmin |
|
|
height: Math.max(r1.y + r1.height, r2.y + r2.height) - ymin |
|
|
|
|
|
return new Frame frame |
|
|
|
|
|
|
@@ -3632,13 +3632,15 @@ require.define("/src/primitives/frame.coffee",function(require,module,exports,__ |
|
|
}); |
|
|
|
|
|
Frame.prototype.merge = function(r2) { |
|
|
var frame, r1; |
|
|
var frame, r1, xmin, ymin; |
|
|
r1 = this; |
|
|
xmin = Math.min(r1.x, r2.x); |
|
|
ymin = Math.min(r1.y, r2.y); |
|
|
frame = { |
|
|
x: Math.min(r1.x, r2.x), |
|
|
y: Math.min(r1.y, r2.y), |
|
|
width: Math.max(r1.width, (r2.x - r1.x) + r2.width), |
|
|
height: Math.max(r1.height, (r2.y - r1.y) + r2.height) |
|
|
x: xmin, |
|
|
y: ymin, |
|
|
width: Math.max(r1.x + r1.width, r2.x + r2.width) - xmin, |
|
|
height: Math.max(r1.y + r1.height, r2.y + r2.height) - ymin |
|
|
}; |
|
|
return new Frame(frame); |
|
|
}; |
|
|
|
@@ -58,7 +58,28 @@ describe "View", -> |
|
|
view.y.should.equal frame.y |
|
|
view.width.should.equal frame.width |
|
|
view.height.should.equal frame.height |
|
|
|
|
|
|
|
|
it "should merge view with frame", -> |
|
|
view = createView() |
|
|
frameB = {x:200, y:200, width:200, height:200} |
|
|
frameTest = view.merge(frameB) |
|
|
frameTest.x.should.equal 0 |
|
|
frameTest.y.should.equal 0 |
|
|
frameTest.width.should.equal 400 |
|
|
frameTest.height.should.equal 400 |
|
|
viewB = new View width:500, height:500 |
|
|
frameTest = viewB.merge(frameB) |
|
|
frameTest.x.should.equal 0 |
|
|
frameTest.y.should.equal 0 |
|
|
frameTest.width.should.equal 500 |
|
|
frameTest.height.should.equal 500 |
|
|
frameC = {x:-30, y:-40, width:200, height:200} |
|
|
frameTest = viewB.merge(frameC) |
|
|
frameTest.x.should.equal -30 |
|
|
frameTest.y.should.equal -40 |
|
|
frameTest.width.should.equal 530 |
|
|
frameTest.height.should.equal 540 |
|
|
|
|
|
describe "Visual", -> |
|
|
|
|
|
["scaleX", "scaleY", "scaleZ"].map (p) -> |
|
|