verstak 0.24.125 → 0.24.128
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/build/dist/source/archive/RxDomV1.js +1 -1
- package/build/dist/source/html/El.d.ts +22 -24
- package/build/dist/source/html/El.js +35 -35
- package/build/dist/source/html/Elements.d.ts +3 -2
- package/build/dist/source/html/Elements.js +12 -9
- package/build/dist/source/html/Handlers.d.ts +6 -0
- package/build/dist/source/html/Handlers.js +55 -0
- package/build/dist/source/html/HtmlApiExt.d.ts +2 -0
- package/build/dist/source/html/HtmlApiExt.js +11 -1
- package/build/dist/source/html/HtmlElements.js +174 -174
- package/build/dist/source/html/api.d.ts +1 -1
- package/build/dist/source/html/api.js +1 -1
- package/build/dist/source/html/sensors/BasePointerSensor.d.ts +5 -5
- package/build/dist/source/html/sensors/BasePointerSensor.js +11 -11
- package/build/dist/source/html/sensors/ButtonSensor.d.ts +6 -6
- package/build/dist/source/html/sensors/ButtonSensor.js +39 -48
- package/build/dist/source/html/sensors/DataForSensor.d.ts +1 -0
- package/build/dist/source/html/sensors/DataForSensor.js +1 -0
- package/build/dist/source/html/sensors/FocusSensor.d.ts +2 -2
- package/build/dist/source/html/sensors/FocusSensor.js +14 -17
- package/build/dist/source/html/sensors/HoverSensor.d.ts +15 -4
- package/build/dist/source/html/sensors/HoverSensor.js +65 -24
- package/build/dist/source/html/sensors/HtmlDragSensor.d.ts +2 -2
- package/build/dist/source/html/sensors/HtmlDragSensor.js +25 -34
- package/build/dist/source/html/sensors/HtmlElementSensor.d.ts +3 -3
- package/build/dist/source/html/sensors/HtmlElementSensor.js +7 -4
- package/build/dist/source/html/sensors/HtmlSensors.d.ts +23 -11
- package/build/dist/source/html/sensors/HtmlSensors.js +81 -35
- package/build/dist/source/html/sensors/KeyboardSensor.d.ts +17 -17
- package/build/dist/source/html/sensors/KeyboardSensor.js +42 -51
- package/build/dist/source/html/sensors/PointerSensor.d.ts +3 -2
- package/build/dist/source/html/sensors/PointerSensor.js +28 -38
- package/build/dist/source/html/sensors/ScrollSensor.d.ts +12 -0
- package/build/dist/source/html/sensors/ScrollSensor.js +62 -0
- package/build/dist/source/html/sensors/WheelSensor.d.ts +2 -2
- package/build/dist/source/html/sensors/WheelSensor.js +11 -20
- package/package.json +8 -8
- package/build/dist/source/html/ReactingFocuser.d.ts +0 -2
- package/build/dist/source/html/ReactingFocuser.js +0 -20
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
};
|
|
10
|
-
import { transactional } from "reactronic";
|
|
11
1
|
import { FocusSensor } from "./FocusSensor.js";
|
|
12
2
|
import { HoverSensor } from "./HoverSensor.js";
|
|
13
3
|
import { HtmlDragSensor } from "./HtmlDragSensor.js";
|
|
@@ -15,33 +5,89 @@ import { KeyboardSensor } from "./KeyboardSensor.js";
|
|
|
15
5
|
import { ButtonSensor } from "./ButtonSensor.js";
|
|
16
6
|
import { ResizeSensor } from "./ResizeSensor.js";
|
|
17
7
|
import { WheelSensor } from "./WheelSensor.js";
|
|
8
|
+
import { ScrollSensor } from "./ScrollSensor.js";
|
|
18
9
|
import { WindowSensor } from "./WindowSensor.js";
|
|
19
10
|
import { PointerSensor } from "./PointerSensor.js";
|
|
20
11
|
export class HtmlSensors {
|
|
21
|
-
|
|
22
|
-
this.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
this.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
this.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
this.
|
|
12
|
+
get window() {
|
|
13
|
+
if (this._window === undefined) {
|
|
14
|
+
this._window = new WindowSensor();
|
|
15
|
+
}
|
|
16
|
+
return this._window;
|
|
17
|
+
}
|
|
18
|
+
get focus() {
|
|
19
|
+
if (this._focus === undefined) {
|
|
20
|
+
this._focus = new FocusSensor(this._element, this.window);
|
|
21
|
+
this._focus.listen();
|
|
22
|
+
}
|
|
23
|
+
return this._focus;
|
|
24
|
+
}
|
|
25
|
+
get hover() {
|
|
26
|
+
if (this._hover === undefined) {
|
|
27
|
+
this._hover = new HoverSensor(this._element);
|
|
28
|
+
this._hover.listen();
|
|
29
|
+
}
|
|
30
|
+
return this._hover;
|
|
31
|
+
}
|
|
32
|
+
get keyboard() {
|
|
33
|
+
if (this._keyboard === undefined) {
|
|
34
|
+
this._keyboard = new KeyboardSensor(this._element);
|
|
35
|
+
this._keyboard.listen();
|
|
36
|
+
}
|
|
37
|
+
return this._keyboard;
|
|
38
|
+
}
|
|
39
|
+
get wheel() {
|
|
40
|
+
if (this._wheel === undefined) {
|
|
41
|
+
this._wheel = new WheelSensor(this._element);
|
|
42
|
+
this._wheel.listen();
|
|
43
|
+
}
|
|
44
|
+
return this._wheel;
|
|
45
|
+
}
|
|
46
|
+
get scroll() {
|
|
47
|
+
if (this._scroll === undefined) {
|
|
48
|
+
this._scroll = new ScrollSensor(this._element);
|
|
49
|
+
this._scroll.listen();
|
|
50
|
+
}
|
|
51
|
+
return this._scroll;
|
|
52
|
+
}
|
|
53
|
+
get resize() {
|
|
54
|
+
if (this._resize === undefined) {
|
|
55
|
+
this._resize = new ResizeSensor();
|
|
56
|
+
}
|
|
57
|
+
return this._resize;
|
|
58
|
+
}
|
|
59
|
+
get htmlDrag() {
|
|
60
|
+
if (this._htmlDrag === undefined) {
|
|
61
|
+
this._htmlDrag = new HtmlDragSensor(this._element, this.focus, this.window);
|
|
62
|
+
this._htmlDrag.listen();
|
|
63
|
+
}
|
|
64
|
+
return this._htmlDrag;
|
|
65
|
+
}
|
|
66
|
+
get button() {
|
|
67
|
+
if (this._button === undefined) {
|
|
68
|
+
this._button = new ButtonSensor(this._element, this.focus, this.window);
|
|
69
|
+
this._button.listen();
|
|
70
|
+
}
|
|
71
|
+
return this._button;
|
|
72
|
+
}
|
|
73
|
+
get pointer() {
|
|
74
|
+
if (this._pointer === undefined) {
|
|
75
|
+
this._pointer = new PointerSensor(this._element, this.focus, this.window);
|
|
76
|
+
this._pointer.listen();
|
|
77
|
+
}
|
|
78
|
+
return this._pointer;
|
|
79
|
+
}
|
|
80
|
+
constructor(element) {
|
|
81
|
+
this._element = element;
|
|
82
|
+
this._window = undefined;
|
|
83
|
+
this._focus = undefined;
|
|
84
|
+
this._hover = undefined;
|
|
85
|
+
this._keyboard = undefined;
|
|
86
|
+
this._wheel = undefined;
|
|
87
|
+
this._scroll = undefined;
|
|
88
|
+
this._resize = undefined;
|
|
89
|
+
this._htmlDrag = undefined;
|
|
90
|
+
this._button = undefined;
|
|
91
|
+
this._pointer = undefined;
|
|
40
92
|
}
|
|
41
93
|
}
|
|
42
|
-
__decorate([
|
|
43
|
-
transactional,
|
|
44
|
-
__metadata("design:type", Function),
|
|
45
|
-
__metadata("design:paramtypes", [Object, Boolean]),
|
|
46
|
-
__metadata("design:returntype", void 0)
|
|
47
|
-
], HtmlSensors.prototype, "listen", null);
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import { HtmlElementSensor } from "./HtmlElementSensor.js";
|
|
2
2
|
export declare enum KeyboardModifiers {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
3
|
+
none = 0,
|
|
4
|
+
ctrl = 1,
|
|
5
|
+
shift = 2,
|
|
6
|
+
alt = 4,
|
|
7
|
+
meta = 8,
|
|
8
|
+
ctrlShift = 3,
|
|
9
|
+
ctrlAlt = 5,
|
|
10
|
+
ctrlMeta = 9,
|
|
11
|
+
ctrlShiftAlt = 7,
|
|
12
|
+
ctrlShiftAltMeta = 15,
|
|
13
|
+
ctrlShiftMeta = 11,
|
|
14
|
+
shiftAlt = 6,
|
|
15
|
+
shiftMeta = 10,
|
|
16
|
+
shiftAltMeta = 14,
|
|
17
|
+
altMeta = 12
|
|
18
18
|
}
|
|
19
19
|
export declare class KeyboardSensor extends HtmlElementSensor {
|
|
20
20
|
down: string;
|
|
21
21
|
up: string;
|
|
22
22
|
modifiers: KeyboardModifiers;
|
|
23
|
-
constructor();
|
|
24
|
-
listen(
|
|
23
|
+
constructor(element: HTMLElement | SVGElement);
|
|
24
|
+
listen(enabled?: boolean): void;
|
|
25
25
|
reset(): void;
|
|
26
26
|
protected onKeyDown(e: KeyboardEvent): void;
|
|
27
27
|
protected onKeyUp(e: KeyboardEvent): void;
|
|
@@ -12,41 +12,38 @@ import { grabElementDataList, SymDataForSensor } from "./DataForSensor.js";
|
|
|
12
12
|
import { HtmlElementSensor } from "./HtmlElementSensor.js";
|
|
13
13
|
export var KeyboardModifiers;
|
|
14
14
|
(function (KeyboardModifiers) {
|
|
15
|
-
KeyboardModifiers[KeyboardModifiers["
|
|
16
|
-
KeyboardModifiers[KeyboardModifiers["
|
|
17
|
-
KeyboardModifiers[KeyboardModifiers["
|
|
18
|
-
KeyboardModifiers[KeyboardModifiers["
|
|
19
|
-
KeyboardModifiers[KeyboardModifiers["
|
|
20
|
-
KeyboardModifiers[KeyboardModifiers["
|
|
21
|
-
KeyboardModifiers[KeyboardModifiers["
|
|
22
|
-
KeyboardModifiers[KeyboardModifiers["
|
|
23
|
-
KeyboardModifiers[KeyboardModifiers["
|
|
24
|
-
KeyboardModifiers[KeyboardModifiers["
|
|
25
|
-
KeyboardModifiers[KeyboardModifiers["
|
|
26
|
-
KeyboardModifiers[KeyboardModifiers["
|
|
27
|
-
KeyboardModifiers[KeyboardModifiers["
|
|
28
|
-
KeyboardModifiers[KeyboardModifiers["
|
|
29
|
-
KeyboardModifiers[KeyboardModifiers["
|
|
15
|
+
KeyboardModifiers[KeyboardModifiers["none"] = 0] = "none";
|
|
16
|
+
KeyboardModifiers[KeyboardModifiers["ctrl"] = 1] = "ctrl";
|
|
17
|
+
KeyboardModifiers[KeyboardModifiers["shift"] = 2] = "shift";
|
|
18
|
+
KeyboardModifiers[KeyboardModifiers["alt"] = 4] = "alt";
|
|
19
|
+
KeyboardModifiers[KeyboardModifiers["meta"] = 8] = "meta";
|
|
20
|
+
KeyboardModifiers[KeyboardModifiers["ctrlShift"] = 3] = "ctrlShift";
|
|
21
|
+
KeyboardModifiers[KeyboardModifiers["ctrlAlt"] = 5] = "ctrlAlt";
|
|
22
|
+
KeyboardModifiers[KeyboardModifiers["ctrlMeta"] = 9] = "ctrlMeta";
|
|
23
|
+
KeyboardModifiers[KeyboardModifiers["ctrlShiftAlt"] = 7] = "ctrlShiftAlt";
|
|
24
|
+
KeyboardModifiers[KeyboardModifiers["ctrlShiftAltMeta"] = 15] = "ctrlShiftAltMeta";
|
|
25
|
+
KeyboardModifiers[KeyboardModifiers["ctrlShiftMeta"] = 11] = "ctrlShiftMeta";
|
|
26
|
+
KeyboardModifiers[KeyboardModifiers["shiftAlt"] = 6] = "shiftAlt";
|
|
27
|
+
KeyboardModifiers[KeyboardModifiers["shiftMeta"] = 10] = "shiftMeta";
|
|
28
|
+
KeyboardModifiers[KeyboardModifiers["shiftAltMeta"] = 14] = "shiftAltMeta";
|
|
29
|
+
KeyboardModifiers[KeyboardModifiers["altMeta"] = 12] = "altMeta";
|
|
30
30
|
})(KeyboardModifiers || (KeyboardModifiers = {}));
|
|
31
31
|
export class KeyboardSensor extends HtmlElementSensor {
|
|
32
|
-
constructor() {
|
|
33
|
-
super();
|
|
32
|
+
constructor(element) {
|
|
33
|
+
super(element);
|
|
34
34
|
this.down = "";
|
|
35
35
|
this.up = "";
|
|
36
|
-
this.modifiers = KeyboardModifiers.
|
|
36
|
+
this.modifiers = KeyboardModifiers.none;
|
|
37
37
|
}
|
|
38
|
-
listen(
|
|
39
|
-
const
|
|
40
|
-
if (
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
this.
|
|
46
|
-
|
|
47
|
-
element.addEventListener("keydown", this.onKeyDown.bind(this), { capture: true });
|
|
48
|
-
element.addEventListener("keyup", this.onKeyUp.bind(this), { capture: true });
|
|
49
|
-
}
|
|
38
|
+
listen(enabled = true) {
|
|
39
|
+
const element = this.sourceElement;
|
|
40
|
+
if (enabled) {
|
|
41
|
+
element.addEventListener("keydown", this.onKeyDown.bind(this), { capture: true });
|
|
42
|
+
element.addEventListener("keyup", this.onKeyUp.bind(this), { capture: true });
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
element.removeEventListener("keydown", this.onKeyDown.bind(this), { capture: true });
|
|
46
|
+
element.removeEventListener("keyup", this.onKeyUp.bind(this), { capture: true });
|
|
50
47
|
}
|
|
51
48
|
}
|
|
52
49
|
reset() {
|
|
@@ -54,7 +51,7 @@ export class KeyboardSensor extends HtmlElementSensor {
|
|
|
54
51
|
this.stopPropagation = false;
|
|
55
52
|
this.down = "";
|
|
56
53
|
this.up = "";
|
|
57
|
-
this.modifiers = KeyboardModifiers.
|
|
54
|
+
this.modifiers = KeyboardModifiers.none;
|
|
58
55
|
}
|
|
59
56
|
onKeyDown(e) {
|
|
60
57
|
this.keyDown(e);
|
|
@@ -83,24 +80,18 @@ export class KeyboardSensor extends HtmlElementSensor {
|
|
|
83
80
|
this.revision++;
|
|
84
81
|
}
|
|
85
82
|
static getKeyAsModifierIfAny(key) {
|
|
86
|
-
let modifier = KeyboardModifiers.
|
|
83
|
+
let modifier = KeyboardModifiers.none;
|
|
87
84
|
if (key === "Control")
|
|
88
|
-
modifier = KeyboardModifiers.
|
|
85
|
+
modifier = KeyboardModifiers.ctrl;
|
|
89
86
|
else if (key === "Shift")
|
|
90
|
-
modifier = KeyboardModifiers.
|
|
87
|
+
modifier = KeyboardModifiers.shift;
|
|
91
88
|
else if (key === "Alt")
|
|
92
|
-
modifier = KeyboardModifiers.
|
|
89
|
+
modifier = KeyboardModifiers.alt;
|
|
93
90
|
else if (key === "Meta")
|
|
94
|
-
modifier = KeyboardModifiers.
|
|
91
|
+
modifier = KeyboardModifiers.meta;
|
|
95
92
|
return modifier;
|
|
96
93
|
}
|
|
97
94
|
}
|
|
98
|
-
__decorate([
|
|
99
|
-
transactional,
|
|
100
|
-
__metadata("design:type", Function),
|
|
101
|
-
__metadata("design:paramtypes", [Object, Boolean]),
|
|
102
|
-
__metadata("design:returntype", void 0)
|
|
103
|
-
], KeyboardSensor.prototype, "listen", null);
|
|
104
95
|
__decorate([
|
|
105
96
|
transactional,
|
|
106
97
|
__metadata("design:type", Function),
|
|
@@ -122,22 +113,22 @@ __decorate([
|
|
|
122
113
|
__metadata("design:returntype", void 0)
|
|
123
114
|
], KeyboardSensor.prototype, "keyUp", null);
|
|
124
115
|
export function extractModifierKeys(e) {
|
|
125
|
-
let modifiers = KeyboardModifiers.
|
|
116
|
+
let modifiers = KeyboardModifiers.none;
|
|
126
117
|
if (e.ctrlKey)
|
|
127
|
-
modifiers |= KeyboardModifiers.
|
|
118
|
+
modifiers |= KeyboardModifiers.ctrl;
|
|
128
119
|
else
|
|
129
|
-
modifiers &= ~KeyboardModifiers.
|
|
120
|
+
modifiers &= ~KeyboardModifiers.ctrl;
|
|
130
121
|
if (e.shiftKey)
|
|
131
|
-
modifiers |= KeyboardModifiers.
|
|
122
|
+
modifiers |= KeyboardModifiers.shift;
|
|
132
123
|
else
|
|
133
|
-
modifiers &= ~KeyboardModifiers.
|
|
124
|
+
modifiers &= ~KeyboardModifiers.shift;
|
|
134
125
|
if (e.altKey)
|
|
135
|
-
modifiers |= KeyboardModifiers.
|
|
126
|
+
modifiers |= KeyboardModifiers.alt;
|
|
136
127
|
else
|
|
137
|
-
modifiers &= ~KeyboardModifiers.
|
|
128
|
+
modifiers &= ~KeyboardModifiers.alt;
|
|
138
129
|
if (e.metaKey)
|
|
139
|
-
modifiers |= KeyboardModifiers.
|
|
130
|
+
modifiers |= KeyboardModifiers.meta;
|
|
140
131
|
else
|
|
141
|
-
modifiers &= ~KeyboardModifiers.
|
|
132
|
+
modifiers &= ~KeyboardModifiers.meta;
|
|
142
133
|
return modifiers;
|
|
143
134
|
}
|
|
@@ -34,10 +34,10 @@ export declare class PointerSensor extends BasePointerSensor {
|
|
|
34
34
|
immediatePositionY: number;
|
|
35
35
|
immediateModifiers: KeyboardModifiers;
|
|
36
36
|
static readonly DraggingThreshold = 4;
|
|
37
|
-
constructor(focusSensor: FocusSensor, windowSensor: WindowSensor);
|
|
37
|
+
constructor(element: HTMLElement | SVGElement, focusSensor: FocusSensor, windowSensor: WindowSensor);
|
|
38
38
|
getData(): unknown;
|
|
39
39
|
setData(value: unknown): void;
|
|
40
|
-
listen(
|
|
40
|
+
listen(enabled?: boolean): void;
|
|
41
41
|
protected onPointerDown(e: PointerEvent): void;
|
|
42
42
|
protected onPointerMove(e: PointerEvent): void;
|
|
43
43
|
protected onPointerUp(e: PointerEvent): void;
|
|
@@ -54,6 +54,7 @@ export declare class PointerSensor extends BasePointerSensor {
|
|
|
54
54
|
protected cancelDragging(): void;
|
|
55
55
|
protected reset(): void;
|
|
56
56
|
protected updateClicking(e: PointerEvent): boolean;
|
|
57
|
+
private _getDefaultDataForSensor;
|
|
57
58
|
protected updateDragTarget(e: PointerEvent): void;
|
|
58
59
|
protected whenClickingOrDragging(): void;
|
|
59
60
|
protected whenMoving(): void;
|
|
@@ -12,11 +12,11 @@ import { extractPointerButton, isPointerButtonDown, PointerButton, BasePointerSe
|
|
|
12
12
|
import { findTargetElementData, SymDataForSensor } from "./DataForSensor.js";
|
|
13
13
|
import { extractModifierKeys, KeyboardModifiers } from "./KeyboardSensor.js";
|
|
14
14
|
export class PointerSensor extends BasePointerSensor {
|
|
15
|
-
constructor(focusSensor, windowSensor) {
|
|
16
|
-
super(focusSensor, windowSensor);
|
|
15
|
+
constructor(element, focusSensor, windowSensor) {
|
|
16
|
+
super(element, focusSensor, windowSensor);
|
|
17
17
|
this.hotPositionX = Infinity;
|
|
18
18
|
this.hotPositionY = Infinity;
|
|
19
|
-
this.pointerButton = PointerButton.
|
|
19
|
+
this.pointerButton = PointerButton.none;
|
|
20
20
|
this.tryingDragging = false;
|
|
21
21
|
this.clickable = undefined;
|
|
22
22
|
this.clicking = undefined;
|
|
@@ -37,13 +37,13 @@ export class PointerSensor extends BasePointerSensor {
|
|
|
37
37
|
this.draggingOver = false;
|
|
38
38
|
this.positionX = Infinity;
|
|
39
39
|
this.positionY = Infinity;
|
|
40
|
-
this.modifiers = KeyboardModifiers.
|
|
40
|
+
this.modifiers = KeyboardModifiers.none;
|
|
41
41
|
this.dropX = Infinity;
|
|
42
42
|
this.dropY = Infinity;
|
|
43
43
|
this.dropped = false;
|
|
44
44
|
this.immediatePositionX = Infinity;
|
|
45
45
|
this.immediatePositionY = Infinity;
|
|
46
|
-
this.immediateModifiers = KeyboardModifiers.
|
|
46
|
+
this.immediateModifiers = KeyboardModifiers.none;
|
|
47
47
|
}
|
|
48
48
|
getData() {
|
|
49
49
|
return this.draggingData;
|
|
@@ -51,30 +51,22 @@ export class PointerSensor extends BasePointerSensor {
|
|
|
51
51
|
setData(value) {
|
|
52
52
|
this.draggingData = value;
|
|
53
53
|
}
|
|
54
|
-
listen(
|
|
55
|
-
const
|
|
56
|
-
if (
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
this.sourceElement = element;
|
|
65
|
-
if (element && enabled) {
|
|
66
|
-
element.addEventListener("pointerdown", this.onPointerDown.bind(this), { capture: true });
|
|
67
|
-
element.addEventListener("pointermove", this.onPointerMove.bind(this), { capture: true });
|
|
68
|
-
element.addEventListener("pointerup", this.onPointerUp.bind(this), { capture: true });
|
|
69
|
-
element.addEventListener("lostpointercapture", this.onLostPointerCapture.bind(this), { capture: true });
|
|
70
|
-
element.addEventListener("keydown", this.onKeyDown.bind(this), { capture: true });
|
|
71
|
-
}
|
|
54
|
+
listen(enabled = true) {
|
|
55
|
+
const element = this.sourceElement;
|
|
56
|
+
if (enabled) {
|
|
57
|
+
element.addEventListener("pointerdown", this.onPointerDown.bind(this), { capture: true });
|
|
58
|
+
element.addEventListener("pointermove", this.onPointerMove.bind(this), { capture: true });
|
|
59
|
+
element.addEventListener("pointerup", this.onPointerUp.bind(this), { capture: true });
|
|
60
|
+
element.addEventListener("lostpointercapture", this.onLostPointerCapture.bind(this), { capture: true });
|
|
61
|
+
element.addEventListener("keydown", this.onKeyDown.bind(this), { capture: true });
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
72
64
|
}
|
|
73
65
|
}
|
|
74
66
|
onPointerDown(e) {
|
|
75
67
|
const button = extractPointerButton(e);
|
|
76
68
|
if (!this.dragStarted && this.clickable === undefined &&
|
|
77
|
-
(button === PointerButton.
|
|
69
|
+
(button === PointerButton.left || button === PointerButton.right)) {
|
|
78
70
|
this.tryClickingOrDragging(e);
|
|
79
71
|
}
|
|
80
72
|
}
|
|
@@ -134,20 +126,20 @@ export class PointerSensor extends BasePointerSensor {
|
|
|
134
126
|
this.immediatePositionY = e.clientY;
|
|
135
127
|
}
|
|
136
128
|
tryClickingOrDragging(e) {
|
|
137
|
-
var _a;
|
|
129
|
+
var _a, _b;
|
|
138
130
|
this.preventDefault = false;
|
|
139
131
|
this.stopPropagation = false;
|
|
140
132
|
const targetPath = e.composedPath();
|
|
141
133
|
const underPointer = document.elementsFromPoint(e.clientX, e.clientY);
|
|
142
134
|
const { data, window } = findTargetElementData(targetPath, underPointer, SymDataForSensor, ["click", "draggable"]);
|
|
143
|
-
const clickable = data === null || data === void 0 ? void 0 : data.click;
|
|
135
|
+
const clickable = (_a = data === null || data === void 0 ? void 0 : data.click) !== null && _a !== void 0 ? _a : this._getDefaultDataForSensor(e);
|
|
144
136
|
const draggable = data === null || data === void 0 ? void 0 : data.draggable;
|
|
145
137
|
if (clickable || draggable) {
|
|
146
138
|
this.clickable = clickable;
|
|
147
139
|
this.clicking = clickable;
|
|
148
140
|
this.draggableData = draggable;
|
|
149
141
|
this.tryingDragging = draggable !== undefined;
|
|
150
|
-
this.dragSource = (
|
|
142
|
+
this.dragSource = (_b = findTargetElementData(targetPath, underPointer, SymDataForSensor, ["drag"], true).data) === null || _b === void 0 ? void 0 : _b.drag;
|
|
151
143
|
this.pointerButton = extractPointerButton(e);
|
|
152
144
|
this.startX = e.clientX;
|
|
153
145
|
this.startY = e.clientY;
|
|
@@ -214,7 +206,7 @@ export class PointerSensor extends BasePointerSensor {
|
|
|
214
206
|
this.revision++;
|
|
215
207
|
}
|
|
216
208
|
reset() {
|
|
217
|
-
this.pointerButton = PointerButton.
|
|
209
|
+
this.pointerButton = PointerButton.none;
|
|
218
210
|
this.clickable = undefined;
|
|
219
211
|
this.clicking = undefined;
|
|
220
212
|
this.clicked = undefined;
|
|
@@ -235,20 +227,21 @@ export class PointerSensor extends BasePointerSensor {
|
|
|
235
227
|
this.draggingOver = false;
|
|
236
228
|
this.positionX = Infinity;
|
|
237
229
|
this.positionY = Infinity;
|
|
238
|
-
this.modifiers = KeyboardModifiers.
|
|
230
|
+
this.modifiers = KeyboardModifiers.none;
|
|
239
231
|
this.dropX = Infinity;
|
|
240
232
|
this.dropY = Infinity;
|
|
241
233
|
this.dropped = false;
|
|
242
234
|
this.immediatePositionX = Infinity;
|
|
243
235
|
this.immediatePositionY = Infinity;
|
|
244
|
-
this.immediateModifiers = KeyboardModifiers.
|
|
236
|
+
this.immediateModifiers = KeyboardModifiers.none;
|
|
245
237
|
this.revision++;
|
|
246
238
|
}
|
|
247
239
|
updateClicking(e) {
|
|
248
240
|
var _a;
|
|
249
241
|
const targetPath = e.composedPath();
|
|
250
242
|
const underPointer = document.elementsFromPoint(e.clientX, e.clientY);
|
|
251
|
-
|
|
243
|
+
let clickable = (_a = findTargetElementData(targetPath, underPointer, SymDataForSensor, ["click"]).data) === null || _a === void 0 ? void 0 : _a.click;
|
|
244
|
+
clickable = clickable !== null && clickable !== void 0 ? clickable : this._getDefaultDataForSensor(e);
|
|
252
245
|
const isSameClickable = this.clickable === clickable;
|
|
253
246
|
if (isSameClickable)
|
|
254
247
|
this.clicking = clickable;
|
|
@@ -257,6 +250,9 @@ export class PointerSensor extends BasePointerSensor {
|
|
|
257
250
|
this.immediatePositionY = e.clientY;
|
|
258
251
|
return isSameClickable;
|
|
259
252
|
}
|
|
253
|
+
_getDefaultDataForSensor(e) {
|
|
254
|
+
return e.currentTarget === this.sourceElement ? e.currentTarget : undefined;
|
|
255
|
+
}
|
|
260
256
|
updateDragTarget(e) {
|
|
261
257
|
const targetPath = e.composedPath();
|
|
262
258
|
const underPointer = document.elementsFromPoint(e.clientX, e.clientY);
|
|
@@ -302,12 +298,6 @@ __decorate([
|
|
|
302
298
|
raw,
|
|
303
299
|
__metadata("design:type", Boolean)
|
|
304
300
|
], PointerSensor.prototype, "dropAllowed", void 0);
|
|
305
|
-
__decorate([
|
|
306
|
-
transactional,
|
|
307
|
-
__metadata("design:type", Function),
|
|
308
|
-
__metadata("design:paramtypes", [Object, Boolean]),
|
|
309
|
-
__metadata("design:returntype", void 0)
|
|
310
|
-
], PointerSensor.prototype, "listen", null);
|
|
311
301
|
__decorate([
|
|
312
302
|
transactional,
|
|
313
303
|
options({ logging: LoggingLevel.Off }),
|
|
@@ -324,7 +314,7 @@ __decorate([
|
|
|
324
314
|
], PointerSensor.prototype, "tryClickingOrDragging", null);
|
|
325
315
|
__decorate([
|
|
326
316
|
transactional,
|
|
327
|
-
options({ reentrance: Reentrance.
|
|
317
|
+
options({ reentrance: Reentrance.cancelPrevious, logging: LoggingLevel.Off }),
|
|
328
318
|
__metadata("design:type", Function),
|
|
329
319
|
__metadata("design:paramtypes", [PointerEvent]),
|
|
330
320
|
__metadata("design:returntype", void 0)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { HtmlElementSensor } from "./HtmlElementSensor.js";
|
|
2
|
+
export declare class ScrollSensor extends HtmlElementSensor {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
constructor(element: HTMLElement | SVGElement);
|
|
6
|
+
listen(enabled?: boolean): void;
|
|
7
|
+
reset(): void;
|
|
8
|
+
protected onScroll(e: Event): void;
|
|
9
|
+
protected doScroll(e: Event): void;
|
|
10
|
+
protected doReset(): void;
|
|
11
|
+
protected updateSensorData(e: Event): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { options, Reentrance, transactional, LoggingLevel } from "reactronic";
|
|
11
|
+
import { HtmlElementSensor } from "./HtmlElementSensor.js";
|
|
12
|
+
export class ScrollSensor extends HtmlElementSensor {
|
|
13
|
+
constructor(element) {
|
|
14
|
+
super(element);
|
|
15
|
+
this.x = Infinity;
|
|
16
|
+
this.y = Infinity;
|
|
17
|
+
}
|
|
18
|
+
listen(enabled = true) {
|
|
19
|
+
const element = this.sourceElement;
|
|
20
|
+
if (enabled) {
|
|
21
|
+
element.addEventListener("scroll", this.onScroll.bind(this), { capture: true, passive: true });
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
element.removeEventListener("scroll", this.onScroll.bind(this), { capture: true });
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
reset() {
|
|
28
|
+
this.doReset();
|
|
29
|
+
}
|
|
30
|
+
onScroll(e) {
|
|
31
|
+
this.doScroll(e);
|
|
32
|
+
}
|
|
33
|
+
doScroll(e) {
|
|
34
|
+
this.updateSensorData(e);
|
|
35
|
+
}
|
|
36
|
+
doReset() {
|
|
37
|
+
this.preventDefault = false;
|
|
38
|
+
this.stopPropagation = false;
|
|
39
|
+
this.x = Infinity;
|
|
40
|
+
this.y = Infinity;
|
|
41
|
+
}
|
|
42
|
+
updateSensorData(e) {
|
|
43
|
+
this.preventDefault = false;
|
|
44
|
+
this.stopPropagation = false;
|
|
45
|
+
this.x = this.sourceElement.scrollLeft;
|
|
46
|
+
this.y = this.sourceElement.scrollTop;
|
|
47
|
+
this.revision++;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
__decorate([
|
|
51
|
+
transactional,
|
|
52
|
+
__metadata("design:type", Function),
|
|
53
|
+
__metadata("design:paramtypes", []),
|
|
54
|
+
__metadata("design:returntype", void 0)
|
|
55
|
+
], ScrollSensor.prototype, "reset", null);
|
|
56
|
+
__decorate([
|
|
57
|
+
transactional,
|
|
58
|
+
options({ reentrance: Reentrance.cancelPrevious, logging: LoggingLevel.Off }),
|
|
59
|
+
__metadata("design:type", Function),
|
|
60
|
+
__metadata("design:paramtypes", [Event]),
|
|
61
|
+
__metadata("design:returntype", void 0)
|
|
62
|
+
], ScrollSensor.prototype, "doScroll", null);
|
|
@@ -3,8 +3,8 @@ export declare class WheelSensor extends BasePointerSensor {
|
|
|
3
3
|
target: unknown;
|
|
4
4
|
deltaX: number;
|
|
5
5
|
deltaY: number;
|
|
6
|
-
constructor();
|
|
7
|
-
listen(
|
|
6
|
+
constructor(element: HTMLElement | SVGElement);
|
|
7
|
+
listen(enabled?: boolean): void;
|
|
8
8
|
reset(): void;
|
|
9
9
|
protected onWheel(e: WheelEvent): void;
|
|
10
10
|
protected doWheel(e: WheelEvent): void;
|
|
@@ -12,23 +12,20 @@ import { findTargetElementData, SymDataForSensor } from "./DataForSensor.js";
|
|
|
12
12
|
import { extractModifierKeys, KeyboardModifiers } from "./KeyboardSensor.js";
|
|
13
13
|
import { BasePointerSensor } from "./BasePointerSensor.js";
|
|
14
14
|
export class WheelSensor extends BasePointerSensor {
|
|
15
|
-
constructor() {
|
|
16
|
-
super();
|
|
15
|
+
constructor(element) {
|
|
16
|
+
super(element);
|
|
17
17
|
this.target = undefined;
|
|
18
18
|
this.target = undefined;
|
|
19
19
|
this.deltaX = Infinity;
|
|
20
20
|
this.deltaY = Infinity;
|
|
21
21
|
}
|
|
22
|
-
listen(
|
|
23
|
-
const
|
|
24
|
-
if (
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
this.
|
|
29
|
-
if (element && enabled) {
|
|
30
|
-
element.addEventListener("wheel", this.onWheel.bind(this), { capture: true, passive: true });
|
|
31
|
-
}
|
|
22
|
+
listen(enabled = true) {
|
|
23
|
+
const element = this.sourceElement;
|
|
24
|
+
if (enabled) {
|
|
25
|
+
element.addEventListener("wheel", this.onWheel.bind(this), { capture: true, passive: true });
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
element.removeEventListener("wheel", this.onWheel.bind(this), { capture: true });
|
|
32
29
|
}
|
|
33
30
|
}
|
|
34
31
|
reset() {
|
|
@@ -43,7 +40,7 @@ export class WheelSensor extends BasePointerSensor {
|
|
|
43
40
|
doReset() {
|
|
44
41
|
this.preventDefault = false;
|
|
45
42
|
this.stopPropagation = false;
|
|
46
|
-
this.modifiers = KeyboardModifiers.
|
|
43
|
+
this.modifiers = KeyboardModifiers.none;
|
|
47
44
|
this.positionX = Infinity;
|
|
48
45
|
this.positionY = Infinity;
|
|
49
46
|
this.target = undefined;
|
|
@@ -65,12 +62,6 @@ export class WheelSensor extends BasePointerSensor {
|
|
|
65
62
|
this.revision++;
|
|
66
63
|
}
|
|
67
64
|
}
|
|
68
|
-
__decorate([
|
|
69
|
-
transactional,
|
|
70
|
-
__metadata("design:type", Function),
|
|
71
|
-
__metadata("design:paramtypes", [Object, Boolean]),
|
|
72
|
-
__metadata("design:returntype", void 0)
|
|
73
|
-
], WheelSensor.prototype, "listen", null);
|
|
74
65
|
__decorate([
|
|
75
66
|
transactional,
|
|
76
67
|
__metadata("design:type", Function),
|
|
@@ -79,7 +70,7 @@ __decorate([
|
|
|
79
70
|
], WheelSensor.prototype, "reset", null);
|
|
80
71
|
__decorate([
|
|
81
72
|
transactional,
|
|
82
|
-
options({ reentrance: Reentrance.
|
|
73
|
+
options({ reentrance: Reentrance.cancelPrevious, logging: LoggingLevel.Off }),
|
|
83
74
|
__metadata("design:type", Function),
|
|
84
75
|
__metadata("design:paramtypes", [WheelEvent]),
|
|
85
76
|
__metadata("design:returntype", void 0)
|