@sequent-org/moodboard 1.2.86 → 1.2.87
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
|
@@ -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(
|
|
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(
|
|
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
|
-
|
|
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
|
/**
|