@sequent-org/moodboard 1.2.91 → 1.2.93

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.91",
3
+ "version": "1.2.93",
4
4
  "type": "module",
5
5
  "description": "Interactive moodboard",
6
6
  "main": "./src/index.js",
@@ -2040,7 +2040,16 @@ export class SelectTool extends BaseTool {
2040
2040
  console.log('🔍 Browser zoom detection:', {
2041
2041
  zoomFactor,
2042
2042
  basePos: { left: baseLeftPx, top: baseTopPx },
2043
- correctedPos: { left: correctedBaseLeftPx, top: correctedBaseTopPx }
2043
+ correctedPos: { left: correctedBaseLeftPx, top: correctedBaseTopPx },
2044
+ screenPos,
2045
+ window: {
2046
+ innerWidth: window.innerWidth,
2047
+ outerWidth: window.outerWidth,
2048
+ visualViewport: window.visualViewport ? {
2049
+ width: window.visualViewport.width,
2050
+ height: window.visualViewport.height
2051
+ } : null
2052
+ }
2044
2053
  });
2045
2054
 
2046
2055
  const leftPx = Math.round(correctedBaseLeftPx - padLeft);
@@ -2820,9 +2829,29 @@ export class SelectTool extends BaseTool {
2820
2829
  * Получение коэффициента масштабирования браузера
2821
2830
  */
2822
2831
  _getBrowserZoomFactor() {
2823
- // Более надежный способ определения масштаба браузера
2832
+ // Множественные методы определения масштаба браузера для надежности
2833
+ let zoomFactors = [];
2834
+
2835
+ try {
2836
+ // Метод 1: Через window размеры
2837
+ const outerInnerRatio = window.outerWidth / window.innerWidth;
2838
+ if (isFinite(outerInnerRatio) && outerInnerRatio > 0.1 && outerInnerRatio < 10) {
2839
+ zoomFactors.push({ method: 'outerInner', value: outerInnerRatio });
2840
+ }
2841
+ } catch (_) {}
2842
+
2843
+ try {
2844
+ // Метод 2: Через visualViewport если доступно
2845
+ if (window.visualViewport) {
2846
+ const vpZoom = window.innerWidth / window.visualViewport.width;
2847
+ if (isFinite(vpZoom) && vpZoom > 0.1 && vpZoom < 10) {
2848
+ zoomFactors.push({ method: 'visualViewport', value: vpZoom });
2849
+ }
2850
+ }
2851
+ } catch (_) {}
2852
+
2824
2853
  try {
2825
- // Создаем тестовый элемент с фиксированными размерами
2854
+ // Метод 3: Через тестовый элемент (проверяем разные единицы)
2826
2855
  const testEl = document.createElement('div');
2827
2856
  testEl.style.position = 'absolute';
2828
2857
  testEl.style.left = '-9999px';
@@ -2834,20 +2863,38 @@ export class SelectTool extends BaseTool {
2834
2863
 
2835
2864
  document.body.appendChild(testEl);
2836
2865
 
2837
- // Измеряем реальные размеры
2838
2866
  const rect = testEl.getBoundingClientRect();
2839
- const zoomFactor = 100 / rect.width; // 100px / реальная ширина
2867
+ const elemZoom = 100 / rect.width;
2840
2868
 
2841
2869
  document.body.removeChild(testEl);
2842
2870
 
2843
- // Проверяем разумность результата
2844
- if (isFinite(zoomFactor) && zoomFactor > 0.1 && zoomFactor < 10) {
2845
- return zoomFactor;
2871
+ if (isFinite(elemZoom) && elemZoom > 0.1 && elemZoom < 10) {
2872
+ zoomFactors.push({ method: 'testElement', value: elemZoom });
2846
2873
  }
2847
2874
  } catch (_) {}
2848
2875
 
2849
- // Fallback: без коррекции
2850
- return 1.0;
2876
+ // Логирование всех методов для диагностики
2877
+ console.log('🔍 Zoom detection methods:', zoomFactors);
2878
+
2879
+ // Выбираем наиболее подходящий результат
2880
+ if (zoomFactors.length === 0) {
2881
+ return 1.0; // Fallback
2882
+ }
2883
+
2884
+ // Если есть visualViewport, предпочитаем его
2885
+ const vpMethod = zoomFactors.find(f => f.method === 'visualViewport');
2886
+ if (vpMethod) {
2887
+ return vpMethod.value;
2888
+ }
2889
+
2890
+ // Иначе берем outerInner как наиболее стабильный
2891
+ const outerMethod = zoomFactors.find(f => f.method === 'outerInner');
2892
+ if (outerMethod) {
2893
+ return outerMethod.value;
2894
+ }
2895
+
2896
+ // Последний fallback - первый доступный метод
2897
+ return zoomFactors[0].value;
2851
2898
  }
2852
2899
 
2853
2900
  }
@@ -376,9 +376,29 @@ export class HtmlTextLayer {
376
376
  * Получение коэффициента масштабирования браузера
377
377
  */
378
378
  _getBrowserZoomFactor() {
379
- // Более надежный способ определения масштаба браузера
379
+ // Множественные методы определения масштаба браузера для надежности
380
+ let zoomFactors = [];
381
+
382
+ try {
383
+ // Метод 1: Через window размеры
384
+ const outerInnerRatio = window.outerWidth / window.innerWidth;
385
+ if (isFinite(outerInnerRatio) && outerInnerRatio > 0.1 && outerInnerRatio < 10) {
386
+ zoomFactors.push({ method: 'outerInner', value: outerInnerRatio });
387
+ }
388
+ } catch (_) {}
389
+
390
+ try {
391
+ // Метод 2: Через visualViewport если доступно
392
+ if (window.visualViewport) {
393
+ const vpZoom = window.innerWidth / window.visualViewport.width;
394
+ if (isFinite(vpZoom) && vpZoom > 0.1 && vpZoom < 10) {
395
+ zoomFactors.push({ method: 'visualViewport', value: vpZoom });
396
+ }
397
+ }
398
+ } catch (_) {}
399
+
380
400
  try {
381
- // Создаем тестовый элемент с фиксированными размерами
401
+ // Метод 3: Через тестовый элемент (проверяем разные единицы)
382
402
  const testEl = document.createElement('div');
383
403
  testEl.style.position = 'absolute';
384
404
  testEl.style.left = '-9999px';
@@ -390,20 +410,35 @@ export class HtmlTextLayer {
390
410
 
391
411
  document.body.appendChild(testEl);
392
412
 
393
- // Измеряем реальные размеры
394
413
  const rect = testEl.getBoundingClientRect();
395
- const zoomFactor = 100 / rect.width; // 100px / реальная ширина
414
+ const elemZoom = 100 / rect.width;
396
415
 
397
416
  document.body.removeChild(testEl);
398
417
 
399
- // Проверяем разумность результата
400
- if (isFinite(zoomFactor) && zoomFactor > 0.1 && zoomFactor < 10) {
401
- return zoomFactor;
418
+ if (isFinite(elemZoom) && elemZoom > 0.1 && elemZoom < 10) {
419
+ zoomFactors.push({ method: 'testElement', value: elemZoom });
402
420
  }
403
421
  } catch (_) {}
404
422
 
405
- // Fallback: без коррекции
406
- return 1.0;
423
+ // Выбираем наиболее подходящий результат
424
+ if (zoomFactors.length === 0) {
425
+ return 1.0; // Fallback
426
+ }
427
+
428
+ // Если есть visualViewport, предпочитаем его
429
+ const vpMethod = zoomFactors.find(f => f.method === 'visualViewport');
430
+ if (vpMethod) {
431
+ return vpMethod.value;
432
+ }
433
+
434
+ // Иначе берем outerInner как наиболее стабильный
435
+ const outerMethod = zoomFactors.find(f => f.method === 'outerInner');
436
+ if (outerMethod) {
437
+ return outerMethod.value;
438
+ }
439
+
440
+ // Последний fallback - первый доступный метод
441
+ return zoomFactors[0].value;
407
442
  }
408
443
  }
409
444