mirror of
https://github.com/konvajs/konva.git
synced 2025-10-15 12:34:52 +08:00
Add isClientRectOnScreen() method to Node #1086
This commit is contained in:
@@ -3867,4 +3867,30 @@ suite('Node', function () {
|
||||
assert.equal(text00.getClientRect().x, 90);
|
||||
assert.equal(text00.getClientRect().y, 90);
|
||||
});
|
||||
|
||||
// ======================================================
|
||||
test('isClientRectOnScreen() method', function () {
|
||||
var stage = addStage();
|
||||
var layer = new Konva.Layer();
|
||||
var circle = new Konva.Circle({
|
||||
x: stage.getWidth() / 2,
|
||||
y: stage.getHeight() / 2,
|
||||
radius: 30,
|
||||
fill: 'green',
|
||||
stroke: 'black',
|
||||
strokeWidth: 4,
|
||||
});
|
||||
|
||||
layer.add(circle);
|
||||
stage.add(layer);
|
||||
|
||||
assert.equal(circle.isClientRectOnScreen(), true);
|
||||
|
||||
circle.x(-circle.radius() - circle.strokeWidth()/2 - 1); // Move circle 1px outside of visible area
|
||||
assert.equal(circle.isClientRectOnScreen(), false);
|
||||
assert.equal(circle.isClientRectOnScreen(1), true);
|
||||
assert.equal(circle.isClientRectOnScreen({x: 1, y: 0}), true);
|
||||
assert.equal(circle.isClientRectOnScreen({x: 0, y: 1}), false);
|
||||
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user