@hprint/plugins 0.0.1-alpha.2 → 0.0.1-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -152,6 +152,7 @@ class CanvasRuler {
152
152
  private tempGuidelLine: fabric.GuideLine | undefined;
153
153
  private needsRectUpdate: boolean = true;
154
154
  private currentMovingTarget: fabric.Object | undefined;
155
+ private lastViewportTransform: number[] | undefined;
155
156
 
156
157
  constructor(_options: RulerOptions) {
157
158
  // 合并默认配置
@@ -261,7 +262,8 @@ class CanvasRuler {
261
262
  'selection:cleared',
262
263
  this.eventHandler.clearStatus
263
264
  );
264
- this.options.canvas.on('object:added', this.eventHandler.markRectDirtyImmediate);
265
+ // 标尺组件在初始化后似乎高亮了最后一个元素的尺寸,目前不需要这个行为
266
+ // this.options.canvas.on('object:added', this.eventHandler.markRectDirtyImmediate);
265
267
  this.options.canvas.on('selection:created', this.eventHandler.markRectDirtyImmediate);
266
268
  this.options.canvas.on('selection:updated', this.eventHandler.markRectDirtyImmediate);
267
269
  this.options.canvas.on('object:moving', this.eventHandler.markRectDirtyThrottled);
@@ -320,6 +322,16 @@ class CanvasRuler {
320
322
  // if (!this.options.enabled) return;
321
323
  const vpt = this.options.canvas.viewportTransform;
322
324
  if (!vpt) return;
325
+
326
+ // 检查视口是否变化(缩放/平移)
327
+ if (
328
+ !this.lastViewportTransform ||
329
+ this.lastViewportTransform.some((val, index) => val !== vpt[index])
330
+ ) {
331
+ this.needsRectUpdate = true;
332
+ this.lastViewportTransform = [...vpt];
333
+ }
334
+
323
335
  if (this.needsRectUpdate) {
324
336
  if (this.currentMovingTarget) {
325
337
  this.calcObjectRectFromTarget(this.currentMovingTarget);