slightly fix getClientRect calculations

This commit is contained in:
Anton Lavrenov 2018-04-18 11:27:51 +07:00
parent a4221df605
commit e415e266ab
4 changed files with 48 additions and 8 deletions

View File

@ -2,7 +2,7 @@
* Konva JavaScript Framework v2.0.2
* http://konvajs.github.io/
* Licensed under the MIT
* Date: Tue Apr 17 2018
* Date: Wed Apr 18 2018
*
* Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
* Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva)
@ -8133,7 +8133,7 @@
var that = this;
this.children.each(function(child) {
// skip invisible children
if (!child.isVisible()) {
if (!child.getVisible()) {
return;
}
@ -8164,7 +8164,7 @@
var hasVisible = false;
for (var i = 0; i < shapes.length; i++) {
var shape = shapes[i];
if (shape.isVisible()) {
if (shape.getVisible()) {
hasVisible = true;
break;
}
@ -14476,6 +14476,7 @@
});
callback(image);
};
img.crossOrigin = 'Anonymous';
img.src = url;
};
})();

4
konva.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -504,7 +504,7 @@
var that = this;
this.children.each(function(child) {
// skip invisible children
if (!child.isVisible()) {
if (!child.getVisible()) {
return;
}
@ -535,7 +535,7 @@
var hasVisible = false;
for (var i = 0; i < shapes.length; i++) {
var shape = shapes[i];
if (shape.isVisible()) {
if (shape.getVisible()) {
hasVisible = true;
break;
}

View File

@ -2223,7 +2223,7 @@ suite('Container', function() {
});
});
test('getClientRect - test empty group with invisible child', function() {
test('getClientRect - test group with invisible child', function() {
var stage = addStage();
var layer = new Konva.Layer();
stage.add(layer);
@ -2231,6 +2231,45 @@ suite('Container', function() {
x: 10,
y: 10
});
layer.add(group);
layer.draw();
group.add(
new Konva.Rect({
x: 0,
y: 0,
width: 50,
height: 50
})
);
group.add(
new Konva.Rect({
x: 400,
y: 400,
width: 50,
height: 50,
visible: false
})
);
assert.deepEqual(group.getClientRect(), {
x: 10,
y: 10,
width: 50,
height: 50
});
});
test('getClientRect - test group with invisible child inside invisible parent', function() {
var stage = addStage();
var layer = new Konva.Layer({
visible: false
});
stage.add(layer);
var group = new Konva.Group({
x: 10,
y: 10
});
layer.add(group);
layer.draw();
group.add(
new Konva.Rect({
x: 0,