mirror of
https://github.com/konvajs/konva.git
synced 2025-08-20 09:44:17 +08:00
getClientRect calculation fix for groups
This commit is contained in:
parent
04222bfe93
commit
c0911572e7
@ -9,6 +9,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
* Added some text trim logic to wrap in better
|
||||
|
||||
### Fixed
|
||||
|
||||
* `getClientRect` calculation fix for groups
|
||||
|
||||
## [2.4.0][2018-09-19]
|
||||
|
||||
### Added
|
||||
|
||||
7
konva.js
7
konva.js
@ -8400,10 +8400,9 @@
|
||||
var rect = child.getClientRect({ relativeTo: that });
|
||||
|
||||
// skip invisible children (like empty groups)
|
||||
// or don't skip... hmmm...
|
||||
// if (rect.width === 0 && rect.height === 0) {
|
||||
// return;
|
||||
// }
|
||||
if (rect.width === 0 && rect.height === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (minX === undefined) {
|
||||
// initial value for first child
|
||||
|
||||
2
konva.min.js
vendored
2
konva.min.js
vendored
File diff suppressed because one or more lines are too long
@ -509,10 +509,9 @@
|
||||
var rect = child.getClientRect({ relativeTo: that });
|
||||
|
||||
// skip invisible children (like empty groups)
|
||||
// or don't skip... hmmm...
|
||||
// if (rect.width === 0 && rect.height === 0) {
|
||||
// return;
|
||||
// }
|
||||
if (rect.width === 0 && rect.height === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (minX === undefined) {
|
||||
// initial value for first child
|
||||
|
||||
@ -2346,6 +2346,47 @@ suite('Container', function() {
|
||||
});
|
||||
});
|
||||
|
||||
test.only('getClientRect - nested group with a hidden shapes', function() {
|
||||
var stage = addStage();
|
||||
|
||||
var layer = new Konva.Layer();
|
||||
stage.add(layer);
|
||||
|
||||
var group1 = new Konva.Group();
|
||||
layer.add(group1);
|
||||
|
||||
var rect = new Konva.Rect({
|
||||
x: 50,
|
||||
y: 100,
|
||||
width: 200,
|
||||
height: 75,
|
||||
fill: 'red'
|
||||
});
|
||||
group1.add(rect);
|
||||
|
||||
var group2 = new Konva.Group();
|
||||
layer.add(group2);
|
||||
|
||||
var rect2 = new Konva.Rect({
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: 200,
|
||||
height: 75,
|
||||
fill: 'red',
|
||||
visible: false
|
||||
});
|
||||
group1.add(rect2);
|
||||
|
||||
|
||||
|
||||
assert.deepEqual(layer.getClientRect(), {
|
||||
x: 50,
|
||||
y: 100,
|
||||
width: 200,
|
||||
height: 75
|
||||
});
|
||||
});
|
||||
|
||||
test('clip-cache', function() {
|
||||
var stage = addStage();
|
||||
var layer = new Konva.Layer();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user