@sequent-org/moodboard 1.2.99 → 1.2.101

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sequent-org/moodboard",
3
- "version": "1.2.99",
3
+ "version": "1.2.101",
4
4
  "type": "module",
5
5
  "description": "Interactive moodboard",
6
6
  "main": "./src/index.js",
@@ -224,14 +224,14 @@ export class HtmlHandlesLayer {
224
224
  isFrameTarget = mbType === 'frame';
225
225
  }
226
226
 
227
- // Вычисляем позицию и размер через математику сцены (toGlobal) и переводим в CSS px
227
+ // Вычисляем позицию и размер через математику сцены (toGlobal) и переводим в CSS px.
228
+ // toGlobal() возвращает координаты в device-пикселях, поэтому делим на rendererRes.
228
229
  const tl = world.toGlobal(new PIXI.Point(worldBounds.x, worldBounds.y));
229
230
  const br = world.toGlobal(new PIXI.Point(worldBounds.x + worldBounds.width, worldBounds.y + worldBounds.height));
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));
231
+ const cssX = offsetLeft + tl.x / rendererRes;
232
+ const cssY = offsetTop + tl.y / rendererRes;
233
+ const cssWidth = Math.max(1, (br.x - tl.x) / rendererRes);
234
+ const cssHeight = Math.max(1, (br.y - tl.y) / rendererRes);
235
235
 
236
236
  const left = Math.round(cssX);
237
237
  const top = Math.round(cssY);
@@ -405,6 +405,7 @@ export class HtmlHandlesLayer {
405
405
  const s = world?.scale?.x || 1;
406
406
  const tx = world?.x || 0;
407
407
  const ty = world?.y || 0;
408
+ const rendererRes = (this.core.pixi.app.renderer?.resolution) || 1;
408
409
  const containerRect = this.container.getBoundingClientRect();
409
410
  const view = this.core.pixi.app.view;
410
411
  const viewRect = view.getBoundingClientRect();
@@ -423,11 +424,12 @@ export class HtmlHandlesLayer {
423
424
  w: startCSS.width,
424
425
  h: startCSS.height,
425
426
  };
427
+ // Экранные координаты (CSS) → device-пиксели → world
426
428
  const startWorld = {
427
- x: (startScreen.x - tx) / s,
428
- y: (startScreen.y - ty) / s,
429
- width: startScreen.w / s,
430
- height: startScreen.h / s,
429
+ x: ((startScreen.x * rendererRes) - tx) / s,
430
+ y: ((startScreen.y * rendererRes) - ty) / s,
431
+ width: (startScreen.w * rendererRes) / s,
432
+ height: (startScreen.h * rendererRes) / s,
431
433
  };
432
434
 
433
435
  let objects = [id];
@@ -568,10 +570,10 @@ export class HtmlHandlesLayer {
568
570
  const screenY = (newTop - offsetTop);
569
571
  const screenW = newW;
570
572
  const screenH = newH;
571
- const worldX = (screenX - tx) / s;
572
- const worldY = (screenY - ty) / s;
573
- const worldW = screenW / s;
574
- const worldH = screenH / s;
573
+ const worldX = ((screenX * rendererRes) - tx) / s;
574
+ const worldY = ((screenY * rendererRes) - ty) / s;
575
+ const worldW = (screenW * rendererRes) / s;
576
+ const worldH = (screenH * rendererRes) / s;
575
577
 
576
578
  // Определяем, изменилась ли позиция (только для левых/верхних ручек)
577
579
  const positionChanged = (newLeft !== startCSS.left) || (newTop !== startCSS.top);
@@ -616,10 +618,10 @@ export class HtmlHandlesLayer {
616
618
  const screenY = (endCSS.top - offsetTop);
617
619
  const screenW = endCSS.width;
618
620
  const screenH = endCSS.height;
619
- const worldX = (screenX - tx) / s;
620
- const worldY = (screenY - ty) / s;
621
- const worldW = screenW / s;
622
- const worldH = screenH / s;
621
+ const worldX = ((screenX * rendererRes) - tx) / s;
622
+ const worldY = ((screenY * rendererRes) - ty) / s;
623
+ const worldW = (screenW * rendererRes) / s;
624
+ const worldH = (screenH * rendererRes) / s;
623
625
 
624
626
  if (isGroup) {
625
627
  this.eventBus.emit(Events.Tool.GroupResizeEnd, { objects });
@@ -681,6 +683,7 @@ export class HtmlHandlesLayer {
681
683
  const s = world?.scale?.x || 1;
682
684
  const tx = world?.x || 0;
683
685
  const ty = world?.y || 0;
686
+ const rendererRes = (this.core.pixi.app.renderer?.resolution) || 1;
684
687
  const containerRect = this.container.getBoundingClientRect();
685
688
  const view = this.core.pixi.app.view;
686
689
  const viewRect = view.getBoundingClientRect();
@@ -701,10 +704,10 @@ export class HtmlHandlesLayer {
701
704
  h: startCSS.height,
702
705
  };
703
706
  const startWorld = {
704
- x: (startScreen.x - tx) / s,
705
- y: (startScreen.y - ty) / s,
706
- width: startScreen.w / s,
707
- height: startScreen.h / s,
707
+ x: ((startScreen.x * rendererRes) - tx) / s,
708
+ y: ((startScreen.y * rendererRes) - ty) / s,
709
+ width: (startScreen.w * rendererRes) / s,
710
+ height: (startScreen.h * rendererRes) / s,
708
711
  };
709
712
 
710
713
  let objects = [id];
@@ -830,10 +833,10 @@ export class HtmlHandlesLayer {
830
833
  const screenY = (newTop - offsetTop);
831
834
  const screenW = newW;
832
835
  const screenH = newH;
833
- const worldX = (screenX - tx) / s;
834
- const worldY = (screenY - ty) / s;
835
- const worldW = screenW / s;
836
- const worldH = screenH / s;
836
+ const worldX = ((screenX * rendererRes) - tx) / s;
837
+ const worldY = ((screenY * rendererRes) - ty) / s;
838
+ const worldW = (screenW * rendererRes) / s;
839
+ const worldH = (screenH * rendererRes) / s;
837
840
 
838
841
  // Определяем, изменилась ли позиция (только для левых/верхних граней)
839
842
  const edgePositionChanged = (newLeft !== startCSS.left) || (newTop !== startCSS.top);
@@ -867,10 +870,10 @@ export class HtmlHandlesLayer {
867
870
  const screenY = (endCSS.top - offsetTop);
868
871
  const screenW = endCSS.width;
869
872
  const screenH = endCSS.height;
870
- const worldX = (screenX - tx) / s;
871
- const worldY = (screenY - ty) / s;
872
- const worldW = screenW / s;
873
- const worldH = screenH / s;
873
+ const worldX = ((screenX * rendererRes) - tx) / s;
874
+ const worldY = ((screenY * rendererRes) - ty) / s;
875
+ const worldW = (screenW * rendererRes) / s;
876
+ const worldH = (screenH * rendererRes) / s;
874
877
 
875
878
  if (isGroup) {
876
879
  this.eventBus.emit(Events.Tool.GroupResizeEnd, { objects });
@@ -888,7 +891,7 @@ export class HtmlHandlesLayer {
888
891
  el.style.width = `${Math.max(1, Math.round(endCSS.width))}px`;
889
892
  el.style.height = 'auto';
890
893
  const measured = Math.max(1, Math.round(el.scrollHeight));
891
- finalWorldH = (measured) / s;
894
+ finalWorldH = (measured * rendererRes) / s;
892
895
  }
893
896
  } catch (_) {}
894
897
  }
@@ -324,12 +324,13 @@ export class HtmlTextLayer {
324
324
  // Преобразуем мировые координаты в экранные через toGlobal
325
325
  const tl = worldLayer.toGlobal(new PIXI.Point(x, y));
326
326
  const br = worldLayer.toGlobal(new PIXI.Point(x + w, y + h));
327
-
328
- // CSS координаты с учетом offset
329
- const left = offsetLeft + tl.x;
330
- const top = offsetTop + tl.y;
331
- const width = Math.max(1, br.x - tl.x);
332
- const height = Math.max(1, br.y - tl.y);
327
+
328
+ // toGlobal() возвращает координаты в device-пикселях с учётом resolution.
329
+ // Для CSS нам нужны логические пиксели, поэтому делим на res.
330
+ const left = offsetLeft + tl.x / res;
331
+ const top = offsetTop + tl.y / res;
332
+ const width = Math.max(1, (br.x - tl.x) / res);
333
+ const height = Math.max(1, (br.y - tl.y) / res);
333
334
 
334
335
  // Применяем к элементу
335
336
  el.style.left = `${left}px`;