mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-18 18:41:08 +00:00
Remove fabric.Group.containsPoint => uses now fabric.Object.containsPoint
Update group unit test - containsPoint checks now scaled group and group with padding Fix text unit test (complexity, toString)
This commit is contained in:
parent
4aa656c549
commit
f0ca6b7b8f
3 changed files with 16 additions and 19 deletions
|
|
@ -384,24 +384,6 @@
|
|||
this.top = (minY + height / 2) || 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* Checks if point is contained within the group
|
||||
* @param {fabric.Point} point point with `x` and `y` properties
|
||||
* @return {Boolean} true if point is contained within group
|
||||
*/
|
||||
containsPoint: function(point) {
|
||||
|
||||
var halfWidth = this.get('width') / 2,
|
||||
halfHeight = this.get('height') / 2,
|
||||
centerX = this.get('left'),
|
||||
centerY = this.get('top');
|
||||
|
||||
return centerX - halfWidth < point.x &&
|
||||
centerX + halfWidth > point.x &&
|
||||
centerY - halfHeight < point.y &&
|
||||
centerY + halfHeight > point.y;
|
||||
},
|
||||
|
||||
/* _TO_SVG_START_ */
|
||||
/**
|
||||
* Returns svg representation of an instance
|
||||
|
|
|
|||
|
|
@ -295,6 +295,20 @@
|
|||
ok(group.containsPoint({ x: 50, y: 120 }));
|
||||
ok(group.containsPoint({ x: 100, y: 100 }));
|
||||
ok(!group.containsPoint({ x: 0, y: 0 }));
|
||||
|
||||
group.scale(2);
|
||||
ok(group.containsPoint({ x: 50, y: 120 }));
|
||||
ok(group.containsPoint({ x: 100, y: 160 }));
|
||||
ok(!group.containsPoint({ x: 0, y: 0 }));
|
||||
ok(!group.containsPoint({ x: 100, y: 170 }));
|
||||
|
||||
group.scale(1);
|
||||
group.padding = 30;
|
||||
group.setCoords();
|
||||
ok(group.containsPoint({ x: 50, y: 120 }));
|
||||
ok(group.containsPoint({ x: 100, y: 170 }));
|
||||
ok(!group.containsPoint({ x: 0, y: 0 }));
|
||||
ok(!group.containsPoint({ x: 100, y: 172 }));
|
||||
});
|
||||
|
||||
test('forEachObject', function() {
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@
|
|||
test('toString', function() {
|
||||
var text = createTextObject();
|
||||
ok(typeof text.toString == 'function');
|
||||
equal(text.toString(), '#<fabric.Text (0): { "text": "x", "fontFamily": "Times New Roman" }>');
|
||||
equal(text.toString(), '#<fabric.Text (1): { "text": "x", "fontFamily": "Times New Roman" }>');
|
||||
});
|
||||
|
||||
test('toObject', function() {
|
||||
|
|
@ -78,6 +78,7 @@
|
|||
test('complexity', function(){
|
||||
var text = createTextObject();
|
||||
ok(typeof text.complexity == 'function');
|
||||
equal(text.complexity(), 1);
|
||||
});
|
||||
|
||||
test('set', function() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue