mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-22 00:07:03 +02:00
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:
@@ -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);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user