@sequent-org/moodboard 1.2.80 → 1.2.82

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.80",
3
+ "version": "1.2.82",
4
4
  "type": "module",
5
5
  "description": "Interactive moodboard",
6
6
  "main": "./src/index.js",
@@ -201,7 +201,7 @@ export class HtmlHandlesLayer {
201
201
  if (!this.layer) return;
202
202
  // Преобразуем world координаты в CSS-пиксели
203
203
  const view = this.core.pixi.app.view;
204
- const res = (this.core.pixi.app.renderer?.resolution) || 1;
204
+ const rendererRes = (this.core.pixi.app.renderer?.resolution) || 1;
205
205
  const containerRect = this.container.getBoundingClientRect();
206
206
  const viewRect = view.getBoundingClientRect();
207
207
  const offsetLeft = viewRect.left - containerRect.left;
@@ -227,10 +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
- const cssX = offsetLeft + (tl.x / res);
231
- const cssY = offsetTop + (tl.y / res);
232
- const cssWidth = Math.max(1, (br.x - tl.x) / res);
233
- const cssHeight = Math.max(1, (br.y - tl.y) / res);
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));
234
235
 
235
236
  const left = Math.round(cssX);
236
237
  const top = Math.round(cssY);
@@ -391,8 +392,8 @@ export class HtmlHandlesLayer {
391
392
  _toWorldScreenInverse(dx, dy) {
392
393
  const world = this.core.pixi.worldLayer || this.core.pixi.app.stage;
393
394
  const s = world?.scale?.x || 1;
394
- const res = (this.core.pixi.app.renderer?.resolution) || 1;
395
- return { dxWorld: (dx * res) / s, dyWorld: (dy * res) / s };
395
+ // dx, dy приходят в CSS-пикселях; для world делим только на масштаб
396
+ return { dxWorld: dx / s, dyWorld: dy / s };
396
397
  }
397
398
 
398
399
  _onHandleDown(e, box) {
@@ -404,9 +405,8 @@ export class HtmlHandlesLayer {
404
405
  const s = world?.scale?.x || 1;
405
406
  const tx = world?.x || 0;
406
407
  const ty = world?.y || 0;
407
- const res = (this.core.pixi.app.renderer?.resolution) || 1;
408
- const view = this.core.pixi.app.view;
409
408
  const containerRect = this.container.getBoundingClientRect();
409
+ const view = this.core.pixi.app.view;
410
410
  const viewRect = view.getBoundingClientRect();
411
411
  const offsetLeft = viewRect.left - containerRect.left;
412
412
  const offsetTop = viewRect.top - containerRect.top;
@@ -418,10 +418,10 @@ export class HtmlHandlesLayer {
418
418
  height: parseFloat(box.style.height),
419
419
  };
420
420
  const startScreen = {
421
- x: (startCSS.left - offsetLeft) * res,
422
- y: (startCSS.top - offsetTop) * res,
423
- w: startCSS.width * res,
424
- h: startCSS.height * res,
421
+ x: (startCSS.left - offsetLeft),
422
+ y: (startCSS.top - offsetTop),
423
+ w: startCSS.width,
424
+ h: startCSS.height,
425
425
  };
426
426
  const startWorld = {
427
427
  x: (startScreen.x - tx) / s,
@@ -564,10 +564,10 @@ export class HtmlHandlesLayer {
564
564
  this._repositionBoxChildren(box);
565
565
 
566
566
  // Перевод в мировые координаты
567
- const screenX = (newLeft - offsetLeft) * res;
568
- const screenY = (newTop - offsetTop) * res;
569
- const screenW = newW * res;
570
- const screenH = newH * res;
567
+ const screenX = (newLeft - offsetLeft);
568
+ const screenY = (newTop - offsetTop);
569
+ const screenW = newW;
570
+ const screenH = newH;
571
571
  const worldX = (screenX - tx) / s;
572
572
  const worldY = (screenY - ty) / s;
573
573
  const worldW = screenW / s;
@@ -612,10 +612,10 @@ export class HtmlHandlesLayer {
612
612
  width: parseFloat(box.style.width),
613
613
  height: parseFloat(box.style.height),
614
614
  };
615
- const screenX = (endCSS.left - offsetLeft) * res;
616
- const screenY = (endCSS.top - offsetTop) * res;
617
- const screenW = endCSS.width * res;
618
- const screenH = endCSS.height * res;
615
+ const screenX = (endCSS.left - offsetLeft);
616
+ const screenY = (endCSS.top - offsetTop);
617
+ const screenW = endCSS.width;
618
+ const screenH = endCSS.height;
619
619
  const worldX = (screenX - tx) / s;
620
620
  const worldY = (screenY - ty) / s;
621
621
  const worldW = screenW / s;
@@ -681,9 +681,8 @@ export class HtmlHandlesLayer {
681
681
  const s = world?.scale?.x || 1;
682
682
  const tx = world?.x || 0;
683
683
  const ty = world?.y || 0;
684
- const res = (this.core.pixi.app.renderer?.resolution) || 1;
685
- const view = this.core.pixi.app.view;
686
684
  const containerRect = this.container.getBoundingClientRect();
685
+ const view = this.core.pixi.app.view;
687
686
  const viewRect = view.getBoundingClientRect();
688
687
  const offsetLeft = viewRect.left - containerRect.left;
689
688
  const offsetTop = viewRect.top - containerRect.top;
@@ -696,10 +695,10 @@ export class HtmlHandlesLayer {
696
695
  height: parseFloat(box.style.height),
697
696
  };
698
697
  const startScreen = {
699
- x: (startCSS.left - offsetLeft) * res,
700
- y: (startCSS.top - offsetTop) * res,
701
- w: startCSS.width * res,
702
- h: startCSS.height * res,
698
+ x: (startCSS.left - offsetLeft),
699
+ y: (startCSS.top - offsetTop),
700
+ w: startCSS.width,
701
+ h: startCSS.height,
703
702
  };
704
703
  const startWorld = {
705
704
  x: (startScreen.x - tx) / s,
@@ -827,10 +826,10 @@ export class HtmlHandlesLayer {
827
826
  this._repositionBoxChildren(box);
828
827
 
829
828
  // Перевод в мировые координаты
830
- const screenX = (newLeft - offsetLeft) * res;
831
- const screenY = (newTop - offsetTop) * res;
832
- const screenW = newW * res;
833
- const screenH = newH * res;
829
+ const screenX = (newLeft - offsetLeft);
830
+ const screenY = (newTop - offsetTop);
831
+ const screenW = newW;
832
+ const screenH = newH;
834
833
  const worldX = (screenX - tx) / s;
835
834
  const worldY = (screenY - ty) / s;
836
835
  const worldW = screenW / s;
@@ -864,10 +863,10 @@ export class HtmlHandlesLayer {
864
863
  width: parseFloat(box.style.width),
865
864
  height: parseFloat(box.style.height),
866
865
  };
867
- const screenX = (endCSS.left - offsetLeft) * res;
868
- const screenY = (endCSS.top - offsetTop) * res;
869
- const screenW = endCSS.width * res;
870
- const screenH = endCSS.height * res;
866
+ const screenX = (endCSS.left - offsetLeft);
867
+ const screenY = (endCSS.top - offsetTop);
868
+ const screenW = endCSS.width;
869
+ const screenH = endCSS.height;
871
870
  const worldX = (screenX - tx) / s;
872
871
  const worldY = (screenY - ty) / s;
873
872
  const worldW = screenW / s;
@@ -889,7 +888,7 @@ export class HtmlHandlesLayer {
889
888
  el.style.width = `${Math.max(1, Math.round(endCSS.width))}px`;
890
889
  el.style.height = 'auto';
891
890
  const measured = Math.max(1, Math.round(el.scrollHeight));
892
- finalWorldH = (measured * res) / s;
891
+ finalWorldH = (measured) / s;
893
892
  }
894
893
  } catch (_) {}
895
894
  }