mirror of
https://github.com/konvajs/konva.git
synced 2025-10-15 12:34:52 +08:00
New ignoreStroke
for Konva.Transformer
, perf fixes
This commit is contained in:
@@ -1004,4 +1004,33 @@ suite('Caching', function() {
|
||||
|
||||
assert.equal(called, false);
|
||||
});
|
||||
|
||||
// for performance reasons
|
||||
it('caching should skip clearing internal caching for perf boos', function() {
|
||||
var stage = addStage();
|
||||
|
||||
var layer = new Konva.Layer();
|
||||
stage.add(layer);
|
||||
|
||||
var bigCircle = new Konva.Circle({
|
||||
x: 100,
|
||||
y: 100,
|
||||
radius: 100,
|
||||
fill: 'green'
|
||||
});
|
||||
layer.add(bigCircle);
|
||||
|
||||
layer.cache();
|
||||
|
||||
var callCount = 0;
|
||||
bigCircle._clearSelfAndDescendantCache = function() {
|
||||
callCount += 1;
|
||||
};
|
||||
|
||||
layer.x(10);
|
||||
assert.equal(callCount, 0);
|
||||
layer.clearCache();
|
||||
// make sure all cleared for children
|
||||
assert.equal(callCount, 1);
|
||||
});
|
||||
});
|
||||
|
@@ -71,7 +71,7 @@ suite('Transformer', function() {
|
||||
assert.equal(tr.rotation(), rect.rotation());
|
||||
});
|
||||
|
||||
test.skip('try to fit rectangle with strokeScaleEnabled = false', function() {
|
||||
test('try to fit rectangle with ignoreStroke = false', function() {
|
||||
var stage = addStage();
|
||||
var layer = new Konva.Layer();
|
||||
stage.add(layer);
|
||||
@@ -90,26 +90,26 @@ suite('Transformer', function() {
|
||||
});
|
||||
layer.add(rect);
|
||||
|
||||
var tr = new Konva.Transformer();
|
||||
var tr = new Konva.Transformer({
|
||||
ignoreStroke: true
|
||||
});
|
||||
layer.add(tr);
|
||||
tr.attachTo(rect);
|
||||
|
||||
layer.draw();
|
||||
|
||||
tr._fitNodeInto({
|
||||
x: 0,
|
||||
y: 0,
|
||||
x: 20,
|
||||
y: 20,
|
||||
width: 200,
|
||||
height: 200
|
||||
});
|
||||
|
||||
var scale = 200 / 140;
|
||||
|
||||
assert.equal(rect.x(), 0);
|
||||
assert.equal(rect.y(), 0);
|
||||
assert.equal(rect.x(), 20);
|
||||
assert.equal(rect.y(), 20);
|
||||
assert.equal(rect.width(), 100);
|
||||
assert.equal(rect.height(), 100);
|
||||
assert.equal(rect.scaleX(), scale);
|
||||
assert.equal(rect.scaleX(), 2);
|
||||
});
|
||||
|
||||
test('listen shape changes', function() {
|
||||
|
Reference in New Issue
Block a user