@sequent-org/moodboard 1.2.86 → 1.2.88

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.86",
3
+ "version": "1.2.88",
4
4
  "type": "module",
5
5
  "description": "Interactive moodboard",
6
6
  "main": "./src/index.js",
@@ -235,7 +235,12 @@ export class PlacementTool extends BaseTool {
235
235
  return;
236
236
  }
237
237
 
238
- const worldPoint = this._toWorld(event.x, event.y);
238
+ // Учитываем масштаб браузера для корректных координат
239
+ const zoomFactor = this._getBrowserZoomFactor();
240
+ const correctedX = event.x * zoomFactor;
241
+ const correctedY = event.y * zoomFactor;
242
+
243
+ const worldPoint = this._toWorld(correctedX, correctedY);
239
244
  // Базовая позиция (может быть переопределена для конкретных типов)
240
245
  let position = {
241
246
  x: Math.round(worldPoint.x - (this.pending.size?.width ?? 100) / 2),
@@ -257,7 +262,9 @@ export class PlacementTool extends BaseTool {
257
262
  try {
258
263
  console.log('🧭 Text click', {
259
264
  cursor: { x: event.x, y: event.y },
260
- world: { x: Math.round(worldPoint.x), y: Math.round(worldPoint.y) }
265
+ corrected: { x: correctedX, y: correctedY },
266
+ world: { x: Math.round(worldPoint.x), y: Math.round(worldPoint.y) },
267
+ zoomFactor: zoomFactor
261
268
  });
262
269
  } catch (_) {}
263
270
  position = {
@@ -530,6 +537,20 @@ export class PlacementTool extends BaseTool {
530
537
  const world = this.app.stage.getChildByName && this.app.stage.getChildByName('worldLayer');
531
538
  return world || this.app.stage;
532
539
  }
540
+
541
+ /**
542
+ * Получение коэффициента масштабирования браузера
543
+ */
544
+ _getBrowserZoomFactor() {
545
+ // Определяем масштаб браузера разными способами
546
+ const outerInnerRatio = window.outerWidth / window.innerWidth;
547
+ const devicePixelRatio = window.devicePixelRatio || 1;
548
+
549
+ // Используемый подход: соотношение размеров окна браузера
550
+ const zoomFactor = outerInnerRatio;
551
+
552
+ return Math.max(0.1, Math.min(5, zoomFactor)); // Ограничиваем разумными пределами
553
+ }
533
554
 
534
555
  /**
535
556
  * Обработчик движения мыши для обновления позиции "призрака"
@@ -1849,7 +1849,13 @@ export class SelectTool extends BaseTool {
1849
1849
  if (!worldLayer) return { x: wx, y: wy };
1850
1850
  const global = worldLayer.toGlobal(new PIXI.Point(wx, wy));
1851
1851
  const viewRes = (this.app?.renderer?.resolution) || (view.width && view.clientWidth ? (view.width / view.clientWidth) : 1);
1852
- return { x: global.x / viewRes, y: global.y / viewRes };
1852
+
1853
+ // Учитываем масштаб браузера при позиционировании HTML элементов
1854
+ const zoomFactor = this._getBrowserZoomFactor();
1855
+ return {
1856
+ x: (global.x / viewRes) / zoomFactor,
1857
+ y: (global.y / viewRes) / zoomFactor
1858
+ };
1853
1859
  };
1854
1860
  const screenPos = toScreen(position.x, position.y);
1855
1861
 
@@ -2804,5 +2810,19 @@ export class SelectTool extends BaseTool {
2804
2810
  // Обновляем ручки
2805
2811
  this.updateResizeHandles();
2806
2812
  }
2813
+
2814
+ /**
2815
+ * Получение коэффициента масштабирования браузера
2816
+ */
2817
+ _getBrowserZoomFactor() {
2818
+ // Определяем масштаб браузера разными способами
2819
+ const outerInnerRatio = window.outerWidth / window.innerWidth;
2820
+ const devicePixelRatio = window.devicePixelRatio || 1;
2821
+
2822
+ // Используемый подход: соотношение размеров окна браузера
2823
+ const zoomFactor = outerInnerRatio;
2824
+
2825
+ return Math.max(0.1, Math.min(5, zoomFactor)); // Ограничиваем разумными пределами
2826
+ }
2807
2827
 
2808
2828
  }
@@ -32,11 +32,30 @@ export class TextTool extends BaseTool {
32
32
  onMouseDown(event) {
33
33
  super.onMouseDown(event);
34
34
 
35
+ // Учитываем масштаб браузера для корректных координат
36
+ const zoomFactor = this._getBrowserZoomFactor();
37
+ const correctedX = event.x * zoomFactor;
38
+ const correctedY = event.y * zoomFactor;
39
+
40
+ // Диагностика координат для решения проблемы с масштабом браузера
41
+ console.log('🔍 TextTool onMouseDown диагностика:', {
42
+ 'исходные event.x/y': { x: event.x, y: event.y },
43
+ 'zoomFactor': zoomFactor,
44
+ 'исправленные x/y': { x: correctedX, y: correctedY },
45
+ 'window.devicePixelRatio': window.devicePixelRatio,
46
+ 'масштаб браузера': window.outerWidth / window.innerWidth
47
+ });
48
+
35
49
  // Преобразуем экранные координаты в мировые координаты PIXI
36
- const worldPoint = this._toWorld(event.x, event.y);
50
+ const worldPoint = this._toWorld(correctedX, correctedY);
51
+
52
+ console.log('🔍 Преобразование координат:', {
53
+ 'исправленные': { x: correctedX, y: correctedY },
54
+ 'мировые': worldPoint
55
+ });
37
56
 
38
57
  // Проверяем, кликнули ли на существующий текстовый объект
39
- const hitObject = this.getTextObjectAt(event.x, event.y);
58
+ const hitObject = this.getTextObjectAt(correctedX, correctedY);
40
59
 
41
60
  if (hitObject) {
42
61
  this.startEditing(hitObject, event);
@@ -125,6 +144,12 @@ export class TextTool extends BaseTool {
125
144
  // Преобразуем мировые координаты в экранные для HTML элемента
126
145
  const screenPos = this._toScreen(worldX, worldY);
127
146
 
147
+ console.log('🔍 Позиционирование input:', {
148
+ 'мировые координаты': { x: worldX, y: worldY },
149
+ 'экранные координаты': screenPos,
150
+ 'container': this.getContainer()
151
+ });
152
+
128
153
  // Создаем новый input
129
154
  this.textInput = document.createElement('textarea');
130
155
  this.textInput.value = initialText;
@@ -432,7 +457,27 @@ export class TextTool extends BaseTool {
432
457
  if (!world || !world.toGlobal) return { x: worldX, y: worldY };
433
458
  const p = new PIXI.Point(worldX, worldY);
434
459
  const global = world.toGlobal(p);
435
- return { x: global.x, y: global.y };
460
+
461
+ // Обратная коррекция для HTML элементов с учетом масштаба браузера
462
+ const zoomFactor = this._getBrowserZoomFactor();
463
+ return {
464
+ x: global.x / zoomFactor,
465
+ y: global.y / zoomFactor
466
+ };
467
+ }
468
+
469
+ /**
470
+ * Получение коэффициента масштабирования браузера
471
+ */
472
+ _getBrowserZoomFactor() {
473
+ // Определяем масштаб браузера разными способами
474
+ const outerInnerRatio = window.outerWidth / window.innerWidth;
475
+ const devicePixelRatio = window.devicePixelRatio || 1;
476
+
477
+ // Используемый подход: соотношение размеров окна браузера
478
+ const zoomFactor = outerInnerRatio;
479
+
480
+ return Math.max(0.1, Math.min(5, zoomFactor)); // Ограничиваем разумными пределами
436
481
  }
437
482
 
438
483
  /**