mirror of
https://github.com/konvajs/konva.git
synced 2025-07-15 20:42:17 +08:00
transition call back is called using the nodes context. This means that you can access the node with the this keyword
This commit is contained in:
parent
8138d2d286
commit
9160b694ae
@ -2,7 +2,12 @@
|
|||||||
// calculate pixel ratio
|
// calculate pixel ratio
|
||||||
var canvas = document.createElement('canvas'),
|
var canvas = document.createElement('canvas'),
|
||||||
context = canvas.getContext('2d'),
|
context = canvas.getContext('2d'),
|
||||||
devicePixelRatio = window.devicePixelRatio || 1, backingStoreRatio = context.webkitBackingStorePixelRatio || context.mozBackingStorePixelRatio || context.msBackingStorePixelRatio || context.oBackingStorePixelRatio || context.backingStorePixelRatio || 1,
|
devicePixelRatio = window.devicePixelRatio || 1,
|
||||||
|
backingStoreRatio = context.webkitBackingStorePixelRatio
|
||||||
|
|| context.mozBackingStorePixelRatio
|
||||||
|
|| context.msBackingStorePixelRatio
|
||||||
|
|| context.oBackingStorePixelRatio
|
||||||
|
|| context.backingStorePixelRatio || 1,
|
||||||
_pixelRatio = devicePixelRatio / backingStoreRatio;
|
_pixelRatio = devicePixelRatio / backingStoreRatio;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -77,7 +77,7 @@
|
|||||||
node.transAnim.stop();
|
node.transAnim.stop();
|
||||||
node.setAttrs(newAttrs);
|
node.setAttrs(newAttrs);
|
||||||
if(config.callback) {
|
if(config.callback) {
|
||||||
config.callback();
|
config.callback.call(node);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -13,7 +13,8 @@ Test.Modules.TRANSITION = {
|
|||||||
height: 50,
|
height: 50,
|
||||||
fill: 'green',
|
fill: 'green',
|
||||||
stroke: 'black',
|
stroke: 'black',
|
||||||
strokeWidth: 4
|
strokeWidth: 4,
|
||||||
|
id: 'rect'
|
||||||
});
|
});
|
||||||
|
|
||||||
layer.add(rect);
|
layer.add(rect);
|
||||||
@ -37,7 +38,8 @@ Test.Modules.TRANSITION = {
|
|||||||
x: 300,
|
x: 300,
|
||||||
duration: 1,
|
duration: 1,
|
||||||
callback: function() {
|
callback: function() {
|
||||||
test(rect.getX() === 300, 'rect x is not 300');
|
test(this.getX() === 300, 'rect x is not 300');
|
||||||
|
test(this.getId() === 'rect', 'rect id should be rect');
|
||||||
anim.start();
|
anim.start();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user