场景画布缩放监听

This commit is contained in:
joylink_zhaoerwei 2024-01-22 15:54:28 +08:00
parent d75e16db82
commit 1d5221dffb
3 changed files with 5 additions and 5 deletions

View File

@ -1226,12 +1226,12 @@ class VectorGraphicUtil {
const registerScaleChange = function registerScaleChange(obj) { const registerScaleChange = function registerScaleChange(obj) {
if (!obj.scaledListenerOn) { if (!obj.scaledListenerOn) {
obj.scaledListenerOn = true; obj.scaledListenerOn = true;
obj.getGraphicApp().on('viewport-scaled', onScaleChange); obj.getCanvas().scene.on('viewport-scaled', onScaleChange);
} }
}; };
const unregisterScaleChange = function unregisterScaleChange(obj) { const unregisterScaleChange = function unregisterScaleChange(obj) {
obj.scaledListenerOn = false; obj.scaledListenerOn = false;
obj.getGraphicApp().off('viewport-scaled', onScaleChange); obj.getCanvas().scene.off('viewport-scaled', onScaleChange);
}; };
obj.onAddToCanvas = function onAddToCanvas() { obj.onAddToCanvas = function onAddToCanvas() {
obj.updateOnScaled(); obj.updateOnScaled();

View File

@ -1,6 +1,6 @@
{ {
"name": "graphic-pixi", "name": "graphic-pixi",
"version": "0.1.8", "version": "0.1.9",
"description": "基于pixijs的图形应用、绘制应用框架", "description": "基于pixijs的图形应用、绘制应用框架",
"productName": "Graphic-pixi", "productName": "Graphic-pixi",
"author": "walker <shengxuqiang@joylink.club>", "author": "walker <shengxuqiang@joylink.club>",

View File

@ -18,14 +18,14 @@ export class VectorGraphicUtil {
): void { ): void {
if (!obj.scaledListenerOn) { if (!obj.scaledListenerOn) {
obj.scaledListenerOn = true; obj.scaledListenerOn = true;
obj.getGraphicApp().on('viewport-scaled', onScaleChange); obj.getCanvas().scene.on('viewport-scaled', onScaleChange);
} }
}; };
const unregisterScaleChange = function unregisterScaleChange( const unregisterScaleChange = function unregisterScaleChange(
obj: VectorGraphic obj: VectorGraphic
): void { ): void {
obj.scaledListenerOn = false; obj.scaledListenerOn = false;
obj.getGraphicApp().off('viewport-scaled', onScaleChange); obj.getCanvas().scene.off('viewport-scaled', onScaleChange);
}; };
obj.onAddToCanvas = function onAddToCanvas() { obj.onAddToCanvas = function onAddToCanvas() {
obj.updateOnScaled(); obj.updateOnScaled();