@sequent-org/moodboard 1.2.81 → 1.2.83
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/package.json +1 -1
- package/src/moodboard/MoodBoard.js +7 -0
- package/src/ui/HtmlHandlesLayer.js +34 -39
package/package.json
CHANGED
|
@@ -101,6 +101,13 @@ export class MoodBoard {
|
|
|
101
101
|
// Инициализируем UI
|
|
102
102
|
this.initToolbar();
|
|
103
103
|
this.initTopbar();
|
|
104
|
+
// Включаем дефолтную сетку (вариант 1 — line), если у доски нет сохранённой
|
|
105
|
+
try {
|
|
106
|
+
const savedGridType = this.coreMoodboard?.state?.state?.board?.grid?.type;
|
|
107
|
+
if (!savedGridType && this.settingsApplier) {
|
|
108
|
+
this.settingsApplier.apply({ grid: { type: 'line' } });
|
|
109
|
+
}
|
|
110
|
+
} catch (_) {}
|
|
104
111
|
this.initZoombar();
|
|
105
112
|
this.initMapbar();
|
|
106
113
|
this.initContextMenu();
|
|
@@ -227,12 +227,11 @@ export class HtmlHandlesLayer {
|
|
|
227
227
|
// Вычисляем позицию и размер через математику сцены (toGlobal) и переводим в CSS px
|
|
228
228
|
const tl = world.toGlobal(new PIXI.Point(worldBounds.x, worldBounds.y));
|
|
229
229
|
const br = world.toGlobal(new PIXI.Point(worldBounds.x + worldBounds.width, worldBounds.y + worldBounds.height));
|
|
230
|
-
//
|
|
231
|
-
const
|
|
232
|
-
const
|
|
233
|
-
const
|
|
234
|
-
const
|
|
235
|
-
const cssHeight = Math.max(1, (br.y - tl.y) / pxPerCss);
|
|
230
|
+
// Используем координаты в CSS-пикселях напрямую (Pixi toGlobal выдаёт экранные px)
|
|
231
|
+
const cssX = offsetLeft + tl.x;
|
|
232
|
+
const cssY = offsetTop + tl.y;
|
|
233
|
+
const cssWidth = Math.max(1, (br.x - tl.x));
|
|
234
|
+
const cssHeight = Math.max(1, (br.y - tl.y));
|
|
236
235
|
|
|
237
236
|
const left = Math.round(cssX);
|
|
238
237
|
const top = Math.round(cssY);
|
|
@@ -393,10 +392,8 @@ export class HtmlHandlesLayer {
|
|
|
393
392
|
_toWorldScreenInverse(dx, dy) {
|
|
394
393
|
const world = this.core.pixi.worldLayer || this.core.pixi.app.stage;
|
|
395
394
|
const s = world?.scale?.x || 1;
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
const pxPerCss = (view && view.width && viewRect.width) ? (view.width / viewRect.width) : ((this.core.pixi.app.renderer?.resolution) || 1);
|
|
399
|
-
return { dxWorld: (dx * pxPerCss) / s, dyWorld: (dy * pxPerCss) / s };
|
|
395
|
+
// dx, dy приходят в CSS-пикселях; для world делим только на масштаб
|
|
396
|
+
return { dxWorld: dx / s, dyWorld: dy / s };
|
|
400
397
|
}
|
|
401
398
|
|
|
402
399
|
_onHandleDown(e, box) {
|
|
@@ -408,10 +405,9 @@ export class HtmlHandlesLayer {
|
|
|
408
405
|
const s = world?.scale?.x || 1;
|
|
409
406
|
const tx = world?.x || 0;
|
|
410
407
|
const ty = world?.y || 0;
|
|
408
|
+
const containerRect = this.container.getBoundingClientRect();
|
|
411
409
|
const view = this.core.pixi.app.view;
|
|
412
410
|
const viewRect = view.getBoundingClientRect();
|
|
413
|
-
const pxPerCss = (view && view.width && viewRect.width) ? (view.width / viewRect.width) : ((this.core.pixi.app.renderer?.resolution) || 1);
|
|
414
|
-
const containerRect = this.container.getBoundingClientRect();
|
|
415
411
|
const offsetLeft = viewRect.left - containerRect.left;
|
|
416
412
|
const offsetTop = viewRect.top - containerRect.top;
|
|
417
413
|
|
|
@@ -422,10 +418,10 @@ export class HtmlHandlesLayer {
|
|
|
422
418
|
height: parseFloat(box.style.height),
|
|
423
419
|
};
|
|
424
420
|
const startScreen = {
|
|
425
|
-
x: (startCSS.left - offsetLeft)
|
|
426
|
-
y: (startCSS.top - offsetTop)
|
|
427
|
-
w: startCSS.width
|
|
428
|
-
h: startCSS.height
|
|
421
|
+
x: (startCSS.left - offsetLeft),
|
|
422
|
+
y: (startCSS.top - offsetTop),
|
|
423
|
+
w: startCSS.width,
|
|
424
|
+
h: startCSS.height,
|
|
429
425
|
};
|
|
430
426
|
const startWorld = {
|
|
431
427
|
x: (startScreen.x - tx) / s,
|
|
@@ -568,10 +564,10 @@ export class HtmlHandlesLayer {
|
|
|
568
564
|
this._repositionBoxChildren(box);
|
|
569
565
|
|
|
570
566
|
// Перевод в мировые координаты
|
|
571
|
-
const screenX = (newLeft - offsetLeft)
|
|
572
|
-
const screenY = (newTop - offsetTop)
|
|
573
|
-
const screenW = newW
|
|
574
|
-
const screenH = newH
|
|
567
|
+
const screenX = (newLeft - offsetLeft);
|
|
568
|
+
const screenY = (newTop - offsetTop);
|
|
569
|
+
const screenW = newW;
|
|
570
|
+
const screenH = newH;
|
|
575
571
|
const worldX = (screenX - tx) / s;
|
|
576
572
|
const worldY = (screenY - ty) / s;
|
|
577
573
|
const worldW = screenW / s;
|
|
@@ -616,10 +612,10 @@ export class HtmlHandlesLayer {
|
|
|
616
612
|
width: parseFloat(box.style.width),
|
|
617
613
|
height: parseFloat(box.style.height),
|
|
618
614
|
};
|
|
619
|
-
const screenX = (endCSS.left - offsetLeft)
|
|
620
|
-
const screenY = (endCSS.top - offsetTop)
|
|
621
|
-
const screenW = endCSS.width
|
|
622
|
-
const screenH = endCSS.height
|
|
615
|
+
const screenX = (endCSS.left - offsetLeft);
|
|
616
|
+
const screenY = (endCSS.top - offsetTop);
|
|
617
|
+
const screenW = endCSS.width;
|
|
618
|
+
const screenH = endCSS.height;
|
|
623
619
|
const worldX = (screenX - tx) / s;
|
|
624
620
|
const worldY = (screenY - ty) / s;
|
|
625
621
|
const worldW = screenW / s;
|
|
@@ -685,10 +681,9 @@ export class HtmlHandlesLayer {
|
|
|
685
681
|
const s = world?.scale?.x || 1;
|
|
686
682
|
const tx = world?.x || 0;
|
|
687
683
|
const ty = world?.y || 0;
|
|
684
|
+
const containerRect = this.container.getBoundingClientRect();
|
|
688
685
|
const view = this.core.pixi.app.view;
|
|
689
686
|
const viewRect = view.getBoundingClientRect();
|
|
690
|
-
const pxPerCss = (view && view.width && viewRect.width) ? (view.width / viewRect.width) : ((this.core.pixi.app.renderer?.resolution) || 1);
|
|
691
|
-
const containerRect = this.container.getBoundingClientRect();
|
|
692
687
|
const offsetLeft = viewRect.left - containerRect.left;
|
|
693
688
|
const offsetTop = viewRect.top - containerRect.top;
|
|
694
689
|
|
|
@@ -700,10 +695,10 @@ export class HtmlHandlesLayer {
|
|
|
700
695
|
height: parseFloat(box.style.height),
|
|
701
696
|
};
|
|
702
697
|
const startScreen = {
|
|
703
|
-
x: (startCSS.left - offsetLeft)
|
|
704
|
-
y: (startCSS.top - offsetTop)
|
|
705
|
-
w: startCSS.width
|
|
706
|
-
h: startCSS.height
|
|
698
|
+
x: (startCSS.left - offsetLeft),
|
|
699
|
+
y: (startCSS.top - offsetTop),
|
|
700
|
+
w: startCSS.width,
|
|
701
|
+
h: startCSS.height,
|
|
707
702
|
};
|
|
708
703
|
const startWorld = {
|
|
709
704
|
x: (startScreen.x - tx) / s,
|
|
@@ -831,10 +826,10 @@ export class HtmlHandlesLayer {
|
|
|
831
826
|
this._repositionBoxChildren(box);
|
|
832
827
|
|
|
833
828
|
// Перевод в мировые координаты
|
|
834
|
-
const screenX = (newLeft - offsetLeft)
|
|
835
|
-
const screenY = (newTop - offsetTop)
|
|
836
|
-
const screenW = newW
|
|
837
|
-
const screenH = newH
|
|
829
|
+
const screenX = (newLeft - offsetLeft);
|
|
830
|
+
const screenY = (newTop - offsetTop);
|
|
831
|
+
const screenW = newW;
|
|
832
|
+
const screenH = newH;
|
|
838
833
|
const worldX = (screenX - tx) / s;
|
|
839
834
|
const worldY = (screenY - ty) / s;
|
|
840
835
|
const worldW = screenW / s;
|
|
@@ -868,10 +863,10 @@ export class HtmlHandlesLayer {
|
|
|
868
863
|
width: parseFloat(box.style.width),
|
|
869
864
|
height: parseFloat(box.style.height),
|
|
870
865
|
};
|
|
871
|
-
const screenX = (endCSS.left - offsetLeft)
|
|
872
|
-
const screenY = (endCSS.top - offsetTop)
|
|
873
|
-
const screenW = endCSS.width
|
|
874
|
-
const screenH = endCSS.height
|
|
866
|
+
const screenX = (endCSS.left - offsetLeft);
|
|
867
|
+
const screenY = (endCSS.top - offsetTop);
|
|
868
|
+
const screenW = endCSS.width;
|
|
869
|
+
const screenH = endCSS.height;
|
|
875
870
|
const worldX = (screenX - tx) / s;
|
|
876
871
|
const worldY = (screenY - ty) / s;
|
|
877
872
|
const worldW = screenW / s;
|
|
@@ -893,7 +888,7 @@ export class HtmlHandlesLayer {
|
|
|
893
888
|
el.style.width = `${Math.max(1, Math.round(endCSS.width))}px`;
|
|
894
889
|
el.style.height = 'auto';
|
|
895
890
|
const measured = Math.max(1, Math.round(el.scrollHeight));
|
|
896
|
-
finalWorldH = (measured
|
|
891
|
+
finalWorldH = (measured) / s;
|
|
897
892
|
}
|
|
898
893
|
} catch (_) {}
|
|
899
894
|
}
|