@sequent-org/moodboard 1.2.90 → 1.2.91

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.90",
3
+ "version": "1.2.91",
4
4
  "type": "module",
5
5
  "description": "Interactive moodboard",
6
6
  "main": "./src/index.js",
@@ -2037,6 +2037,12 @@ export class SelectTool extends BaseTool {
2037
2037
  const correctedBaseLeftPx = baseLeftPx / zoomFactor;
2038
2038
  const correctedBaseTopPx = baseTopPx / zoomFactor;
2039
2039
 
2040
+ console.log('🔍 Browser zoom detection:', {
2041
+ zoomFactor,
2042
+ basePos: { left: baseLeftPx, top: baseTopPx },
2043
+ correctedPos: { left: correctedBaseLeftPx, top: correctedBaseTopPx }
2044
+ });
2045
+
2040
2046
  const leftPx = Math.round(correctedBaseLeftPx - padLeft);
2041
2047
  const topPx = create
2042
2048
  ? Math.round(correctedBaseTopPx - padTop - (lineHeightPx / 2)) // по клику совмещаем центр строки с точкой клика
@@ -2814,14 +2820,34 @@ export class SelectTool extends BaseTool {
2814
2820
  * Получение коэффициента масштабирования браузера
2815
2821
  */
2816
2822
  _getBrowserZoomFactor() {
2817
- // Определяем масштаб браузера разными способами
2818
- const outerInnerRatio = window.outerWidth / window.innerWidth;
2819
- const devicePixelRatio = window.devicePixelRatio || 1;
2820
-
2821
- // Используемый подход: соотношение размеров окна браузера
2822
- const zoomFactor = outerInnerRatio;
2823
+ // Более надежный способ определения масштаба браузера
2824
+ try {
2825
+ // Создаем тестовый элемент с фиксированными размерами
2826
+ const testEl = document.createElement('div');
2827
+ testEl.style.position = 'absolute';
2828
+ testEl.style.left = '-9999px';
2829
+ testEl.style.top = '-9999px';
2830
+ testEl.style.width = '100px';
2831
+ testEl.style.height = '100px';
2832
+ testEl.style.visibility = 'hidden';
2833
+ testEl.style.pointerEvents = 'none';
2834
+
2835
+ document.body.appendChild(testEl);
2836
+
2837
+ // Измеряем реальные размеры
2838
+ const rect = testEl.getBoundingClientRect();
2839
+ const zoomFactor = 100 / rect.width; // 100px / реальная ширина
2840
+
2841
+ document.body.removeChild(testEl);
2842
+
2843
+ // Проверяем разумность результата
2844
+ if (isFinite(zoomFactor) && zoomFactor > 0.1 && zoomFactor < 10) {
2845
+ return zoomFactor;
2846
+ }
2847
+ } catch (_) {}
2823
2848
 
2824
- return Math.max(0.1, Math.min(5, zoomFactor)); // Ограничиваем разумными пределами
2849
+ // Fallback: без коррекции
2850
+ return 1.0;
2825
2851
  }
2826
2852
 
2827
2853
  }
@@ -376,14 +376,34 @@ export class HtmlTextLayer {
376
376
  * Получение коэффициента масштабирования браузера
377
377
  */
378
378
  _getBrowserZoomFactor() {
379
- // Определяем масштаб браузера разными способами
380
- const outerInnerRatio = window.outerWidth / window.innerWidth;
381
- const devicePixelRatio = window.devicePixelRatio || 1;
382
-
383
- // Используемый подход: соотношение размеров окна браузера
384
- const zoomFactor = outerInnerRatio;
379
+ // Более надежный способ определения масштаба браузера
380
+ try {
381
+ // Создаем тестовый элемент с фиксированными размерами
382
+ const testEl = document.createElement('div');
383
+ testEl.style.position = 'absolute';
384
+ testEl.style.left = '-9999px';
385
+ testEl.style.top = '-9999px';
386
+ testEl.style.width = '100px';
387
+ testEl.style.height = '100px';
388
+ testEl.style.visibility = 'hidden';
389
+ testEl.style.pointerEvents = 'none';
390
+
391
+ document.body.appendChild(testEl);
392
+
393
+ // Измеряем реальные размеры
394
+ const rect = testEl.getBoundingClientRect();
395
+ const zoomFactor = 100 / rect.width; // 100px / реальная ширина
396
+
397
+ document.body.removeChild(testEl);
398
+
399
+ // Проверяем разумность результата
400
+ if (isFinite(zoomFactor) && zoomFactor > 0.1 && zoomFactor < 10) {
401
+ return zoomFactor;
402
+ }
403
+ } catch (_) {}
385
404
 
386
- return Math.max(0.1, Math.min(5, zoomFactor)); // Ограничиваем разумными пределами
405
+ // Fallback: без коррекции
406
+ return 1.0;
387
407
  }
388
408
  }
389
409