@sequent-org/moodboard 1.2.107 → 1.2.108
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
|
@@ -4,9 +4,23 @@ import { BaseTool } from '../BaseTool.js';
|
|
|
4
4
|
export class PanTool extends BaseTool {
|
|
5
5
|
constructor(eventBus) {
|
|
6
6
|
super('pan', eventBus);
|
|
7
|
-
|
|
7
|
+
// По умолчанию курсор для панорамирования — системный move
|
|
8
|
+
this.cursor = 'move';
|
|
8
9
|
this.isDragging = false;
|
|
9
10
|
this.last = { x: 0, y: 0 };
|
|
11
|
+
this.app = null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Активация инструмента панорамирования
|
|
16
|
+
* @param {PIXI.Application} app
|
|
17
|
+
*/
|
|
18
|
+
activate(app) {
|
|
19
|
+
super.activate();
|
|
20
|
+
this.app = app || this.app;
|
|
21
|
+
// При активации сразу показываем курсор move
|
|
22
|
+
this.cursor = 'move';
|
|
23
|
+
this.setCursor();
|
|
10
24
|
}
|
|
11
25
|
|
|
12
26
|
onMouseDown(event) {
|
|
@@ -14,7 +28,9 @@ export class PanTool extends BaseTool {
|
|
|
14
28
|
if (event.button === 0 || event.button === 1) {
|
|
15
29
|
this.isDragging = true;
|
|
16
30
|
this.last = { x: event.x, y: event.y };
|
|
17
|
-
|
|
31
|
+
// Во время активного drag оставляем курсор move,
|
|
32
|
+
// чтобы пользователь всегда видел иконку перемещения
|
|
33
|
+
this.cursor = 'move';
|
|
18
34
|
this.setCursor();
|
|
19
35
|
}
|
|
20
36
|
}
|
|
@@ -30,14 +46,26 @@ export class PanTool extends BaseTool {
|
|
|
30
46
|
onMouseUp(event) {
|
|
31
47
|
if (this.isDragging) {
|
|
32
48
|
this.isDragging = false;
|
|
33
|
-
|
|
49
|
+
// После завершения drag возвращаем курсор move
|
|
50
|
+
this.cursor = 'move';
|
|
34
51
|
this.setCursor();
|
|
35
52
|
}
|
|
36
53
|
}
|
|
37
54
|
|
|
38
55
|
onDeactivate() {
|
|
39
56
|
this.isDragging = false;
|
|
40
|
-
|
|
57
|
+
// Сбрасываем курсор на стандартный для canvas
|
|
58
|
+
this.cursor = '';
|
|
41
59
|
this.setCursor();
|
|
60
|
+
super.onDeactivate();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Устанавливает курсор на canvas PIXI
|
|
65
|
+
*/
|
|
66
|
+
setCursor() {
|
|
67
|
+
if (this.app && this.app.view) {
|
|
68
|
+
this.app.view.style.cursor = this.cursor || '';
|
|
69
|
+
}
|
|
42
70
|
}
|
|
43
71
|
}
|