@sequent-org/moodboard 1.2.92 → 1.2.94
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 +1 -1
- package/src/tools/object-tools/SelectTool.js +73 -57
- package/src/ui/HtmlTextLayer.js +45 -53
package/package.json
CHANGED
|
@@ -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,72 +2829,79 @@ export class SelectTool extends BaseTool {
|
|
|
2820
2829
|
* Получение коэффициента масштабирования браузера
|
|
2821
2830
|
*/
|
|
2822
2831
|
_getBrowserZoomFactor() {
|
|
2823
|
-
//
|
|
2824
|
-
let zoomFactors = [];
|
|
2825
|
-
|
|
2826
|
-
try {
|
|
2827
|
-
// Метод 1: Через window размеры
|
|
2828
|
-
const outerInnerRatio = window.outerWidth / window.innerWidth;
|
|
2829
|
-
if (isFinite(outerInnerRatio) && outerInnerRatio > 0.1 && outerInnerRatio < 10) {
|
|
2830
|
-
zoomFactors.push({ method: 'outerInner', value: outerInnerRatio });
|
|
2831
|
-
}
|
|
2832
|
-
} catch (_) {}
|
|
2833
|
-
|
|
2832
|
+
// Новый подход: через измерение canvas размеров
|
|
2834
2833
|
try {
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2834
|
+
if (this.app && this.app.view) {
|
|
2835
|
+
const canvas = this.app.view;
|
|
2836
|
+
|
|
2837
|
+
// Получаем CSS размеры и реальные размеры canvas
|
|
2838
|
+
const cssWidth = canvas.clientWidth;
|
|
2839
|
+
const cssHeight = canvas.clientHeight;
|
|
2840
|
+
const realWidth = canvas.width;
|
|
2841
|
+
const realHeight = canvas.height;
|
|
2842
|
+
|
|
2843
|
+
// Проверяем device pixel ratio
|
|
2844
|
+
const dpr = window.devicePixelRatio || 1;
|
|
2845
|
+
|
|
2846
|
+
// Вычисляем ожидаемые реальные размеры с учетом DPR
|
|
2847
|
+
const expectedRealWidth = cssWidth * dpr;
|
|
2848
|
+
const expectedRealHeight = cssHeight * dpr;
|
|
2849
|
+
|
|
2850
|
+
// Если реальные размеры отличаются от ожидаемых, значит есть zoom
|
|
2851
|
+
let zoomFactorW = 1.0;
|
|
2852
|
+
let zoomFactorH = 1.0;
|
|
2853
|
+
|
|
2854
|
+
if (expectedRealWidth > 0) {
|
|
2855
|
+
zoomFactorW = realWidth / expectedRealWidth;
|
|
2856
|
+
}
|
|
2857
|
+
if (expectedRealHeight > 0) {
|
|
2858
|
+
zoomFactorH = realHeight / expectedRealHeight;
|
|
2859
|
+
}
|
|
2860
|
+
|
|
2861
|
+
// Берем среднее значение или наиболее близкое к 1.0
|
|
2862
|
+
const avgZoom = (zoomFactorW + zoomFactorH) / 2;
|
|
2863
|
+
|
|
2864
|
+
console.log('🔍 Canvas zoom detection:', {
|
|
2865
|
+
css: { width: cssWidth, height: cssHeight },
|
|
2866
|
+
real: { width: realWidth, height: realHeight },
|
|
2867
|
+
dpr,
|
|
2868
|
+
expected: { width: expectedRealWidth, height: expectedRealHeight },
|
|
2869
|
+
zoom: { width: zoomFactorW, height: zoomFactorH, avg: avgZoom }
|
|
2870
|
+
});
|
|
2871
|
+
|
|
2872
|
+
// Если обнаружили разумное отклонение от 1.0, используем его
|
|
2873
|
+
if (isFinite(avgZoom) && avgZoom > 0.1 && avgZoom < 10 && Math.abs(avgZoom - 1.0) > 0.01) {
|
|
2874
|
+
return avgZoom;
|
|
2840
2875
|
}
|
|
2841
2876
|
}
|
|
2842
2877
|
} catch (_) {}
|
|
2843
2878
|
|
|
2879
|
+
// Fallback: простой метод через screen размеры
|
|
2844
2880
|
try {
|
|
2845
|
-
//
|
|
2846
|
-
const
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
testEl.style.top = '-9999px';
|
|
2850
|
-
testEl.style.width = '100px';
|
|
2851
|
-
testEl.style.height = '100px';
|
|
2852
|
-
testEl.style.visibility = 'hidden';
|
|
2853
|
-
testEl.style.pointerEvents = 'none';
|
|
2854
|
-
|
|
2855
|
-
document.body.appendChild(testEl);
|
|
2856
|
-
|
|
2857
|
-
const rect = testEl.getBoundingClientRect();
|
|
2858
|
-
const elemZoom = 100 / rect.width;
|
|
2859
|
-
|
|
2860
|
-
document.body.removeChild(testEl);
|
|
2881
|
+
// Сравниваем screen.width с window.innerWidth
|
|
2882
|
+
const screenRatio = screen.width / window.innerWidth;
|
|
2883
|
+
const dpr = window.devicePixelRatio || 1;
|
|
2884
|
+
const expectedRatio = dpr;
|
|
2861
2885
|
|
|
2862
|
-
if (
|
|
2863
|
-
|
|
2886
|
+
if (Math.abs(screenRatio - expectedRatio) > 0.1) {
|
|
2887
|
+
const zoomFactor = screenRatio / expectedRatio;
|
|
2888
|
+
|
|
2889
|
+
console.log('🔍 Screen zoom detection:', {
|
|
2890
|
+
screen: { width: screen.width, height: screen.height },
|
|
2891
|
+
window: { innerWidth: window.innerWidth, innerHeight: window.innerHeight },
|
|
2892
|
+
screenRatio,
|
|
2893
|
+
expectedRatio,
|
|
2894
|
+
zoomFactor
|
|
2895
|
+
});
|
|
2896
|
+
|
|
2897
|
+
if (isFinite(zoomFactor) && zoomFactor > 0.1 && zoomFactor < 10) {
|
|
2898
|
+
return zoomFactor;
|
|
2899
|
+
}
|
|
2864
2900
|
}
|
|
2865
2901
|
} catch (_) {}
|
|
2866
2902
|
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
// Выбираем наиболее подходящий результат
|
|
2871
|
-
if (zoomFactors.length === 0) {
|
|
2872
|
-
return 1.0; // Fallback
|
|
2873
|
-
}
|
|
2874
|
-
|
|
2875
|
-
// Если есть visualViewport, предпочитаем его
|
|
2876
|
-
const vpMethod = zoomFactors.find(f => f.method === 'visualViewport');
|
|
2877
|
-
if (vpMethod) {
|
|
2878
|
-
return vpMethod.value;
|
|
2879
|
-
}
|
|
2880
|
-
|
|
2881
|
-
// Иначе берем outerInner как наиболее стабильный
|
|
2882
|
-
const outerMethod = zoomFactors.find(f => f.method === 'outerInner');
|
|
2883
|
-
if (outerMethod) {
|
|
2884
|
-
return outerMethod.value;
|
|
2885
|
-
}
|
|
2886
|
-
|
|
2887
|
-
// Последний fallback - первый доступный метод
|
|
2888
|
-
return zoomFactors[0].value;
|
|
2903
|
+
console.log('🔍 Zoom detection: using fallback (no zoom correction)');
|
|
2904
|
+
return 1.0; // Fallback: без коррекции
|
|
2889
2905
|
}
|
|
2890
2906
|
|
|
2891
2907
|
}
|
package/src/ui/HtmlTextLayer.js
CHANGED
|
@@ -376,69 +376,61 @@ export class HtmlTextLayer {
|
|
|
376
376
|
* Получение коэффициента масштабирования браузера
|
|
377
377
|
*/
|
|
378
378
|
_getBrowserZoomFactor() {
|
|
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
|
-
|
|
379
|
+
// Новый подход: через измерение canvas размеров
|
|
390
380
|
try {
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
381
|
+
if (this.core && this.core.pixi && this.core.pixi.app && this.core.pixi.app.view) {
|
|
382
|
+
const canvas = this.core.pixi.app.view;
|
|
383
|
+
|
|
384
|
+
// Получаем CSS размеры и реальные размеры canvas
|
|
385
|
+
const cssWidth = canvas.clientWidth;
|
|
386
|
+
const cssHeight = canvas.clientHeight;
|
|
387
|
+
const realWidth = canvas.width;
|
|
388
|
+
const realHeight = canvas.height;
|
|
389
|
+
|
|
390
|
+
// Проверяем device pixel ratio
|
|
391
|
+
const dpr = window.devicePixelRatio || 1;
|
|
392
|
+
|
|
393
|
+
// Вычисляем ожидаемые реальные размеры с учетом DPR
|
|
394
|
+
const expectedRealWidth = cssWidth * dpr;
|
|
395
|
+
const expectedRealHeight = cssHeight * dpr;
|
|
396
|
+
|
|
397
|
+
// Если реальные размеры отличаются от ожидаемых, значит есть zoom
|
|
398
|
+
let zoomFactorW = 1.0;
|
|
399
|
+
let zoomFactorH = 1.0;
|
|
400
|
+
|
|
401
|
+
if (expectedRealWidth > 0) {
|
|
402
|
+
zoomFactorW = realWidth / expectedRealWidth;
|
|
403
|
+
}
|
|
404
|
+
if (expectedRealHeight > 0) {
|
|
405
|
+
zoomFactorH = realHeight / expectedRealHeight;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// Берем среднее значение
|
|
409
|
+
const avgZoom = (zoomFactorW + zoomFactorH) / 2;
|
|
410
|
+
|
|
411
|
+
// Если обнаружили разумное отклонение от 1.0, используем его
|
|
412
|
+
if (isFinite(avgZoom) && avgZoom > 0.1 && avgZoom < 10 && Math.abs(avgZoom - 1.0) > 0.01) {
|
|
413
|
+
return avgZoom;
|
|
396
414
|
}
|
|
397
415
|
}
|
|
398
416
|
} catch (_) {}
|
|
399
417
|
|
|
418
|
+
// Fallback: простой метод через screen размеры
|
|
400
419
|
try {
|
|
401
|
-
|
|
402
|
-
const
|
|
403
|
-
|
|
404
|
-
testEl.style.left = '-9999px';
|
|
405
|
-
testEl.style.top = '-9999px';
|
|
406
|
-
testEl.style.width = '100px';
|
|
407
|
-
testEl.style.height = '100px';
|
|
408
|
-
testEl.style.visibility = 'hidden';
|
|
409
|
-
testEl.style.pointerEvents = 'none';
|
|
410
|
-
|
|
411
|
-
document.body.appendChild(testEl);
|
|
412
|
-
|
|
413
|
-
const rect = testEl.getBoundingClientRect();
|
|
414
|
-
const elemZoom = 100 / rect.width;
|
|
420
|
+
const screenRatio = screen.width / window.innerWidth;
|
|
421
|
+
const dpr = window.devicePixelRatio || 1;
|
|
422
|
+
const expectedRatio = dpr;
|
|
415
423
|
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
424
|
+
if (Math.abs(screenRatio - expectedRatio) > 0.1) {
|
|
425
|
+
const zoomFactor = screenRatio / expectedRatio;
|
|
426
|
+
|
|
427
|
+
if (isFinite(zoomFactor) && zoomFactor > 0.1 && zoomFactor < 10) {
|
|
428
|
+
return zoomFactor;
|
|
429
|
+
}
|
|
420
430
|
}
|
|
421
431
|
} catch (_) {}
|
|
422
432
|
|
|
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;
|
|
433
|
+
return 1.0; // Fallback: без коррекции
|
|
442
434
|
}
|
|
443
435
|
}
|
|
444
436
|
|