@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.
- package/dist/index.js +20 -20
- package/dist/index.mjs +2258 -2239
- package/dist/src/plugins/AlignGuidLinePlugin.d.ts +7 -2
- package/dist/src/plugins/AlignGuidLinePlugin.d.ts.map +1 -1
- package/dist/src/plugins/CreateElementPlugin.d.ts +4 -0
- package/dist/src/plugins/CreateElementPlugin.d.ts.map +1 -1
- package/dist/src/plugins/GroupAlignPlugin.d.ts.map +1 -1
- package/dist/src/plugins/LockPlugin.d.ts.map +1 -1
- package/dist/src/plugins/QrCodePlugin.d.ts +5 -0
- package/dist/src/plugins/QrCodePlugin.d.ts.map +1 -1
- package/dist/src/utils/ruler/ruler.d.ts +1 -0
- package/dist/src/utils/ruler/ruler.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/plugins/AlignGuidLinePlugin.ts +195 -184
- package/src/plugins/BarCodePlugin.ts +2 -2
- package/src/plugins/CreateElementPlugin.ts +23 -2
- package/src/plugins/GroupAlignPlugin.ts +2 -2
- package/src/plugins/LockPlugin.ts +3 -1
- package/src/plugins/QrCodePlugin.ts +322 -329
- package/src/utils/ruler/ruler.ts +13 -1
package/src/utils/ruler/ruler.ts
CHANGED
|
@@ -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
|
-
|
|
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);
|