@sequent-org/moodboard 1.2.87 → 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.87",
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
  }