disable Move and Rotate operations if area < 80% contained in the viewport

see #542.
Also included:
1. DRY up code for "% contained in" extent testing.
2. If action.disabled() returns a better reason, show that instead of the too_large one.
This commit is contained in:
Bryan Housel
2014-07-11 17:11:50 -04:00
parent 098a1ac5a7
commit 874a3e2ad6
8 changed files with 83 additions and 38 deletions
+25
View File
@@ -158,4 +158,29 @@ describe("iD.geo.Extent", function () {
expect(b.intersection(a)).to.eql(iD.geo.Extent([1, 1], [2, 2]));
});
});
describe("#percentContainedIn", function () {
it("returns a 0 if self does not intersect other", function () {
var a = iD.geo.Extent([0, 0], [1, 1]),
b = iD.geo.Extent([0, 3], [4, 1]);
expect(a.percentContainedIn(b)).to.eql(0);
expect(b.percentContainedIn(a)).to.eql(0);
});
it("returns the percent contained of self with other (1)", function () {
var a = iD.geo.Extent([0, 0], [2, 1]),
b = iD.geo.Extent([1, 0], [3, 1]);
expect(a.percentContainedIn(b)).to.eql(0.5);
expect(b.percentContainedIn(a)).to.eql(0.5);
});
it("returns the percent contained of self with other (2)", function () {
var a = iD.geo.Extent([0, 0], [4, 1]),
b = iD.geo.Extent([3, 0], [4, 2]);
expect(a.percentContainedIn(b)).to.eql(0.25);
expect(b.percentContainedIn(a)).to.eql(0.5);
});
});
});