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.
Files changed (39) hide show
  1. package/build/dist/source/archive/RxDomV1.js +1 -1
  2. package/build/dist/source/html/El.d.ts +22 -24
  3. package/build/dist/source/html/El.js +35 -35
  4. package/build/dist/source/html/Elements.d.ts +3 -2
  5. package/build/dist/source/html/Elements.js +12 -9
  6. package/build/dist/source/html/Handlers.d.ts +6 -0
  7. package/build/dist/source/html/Handlers.js +55 -0
  8. package/build/dist/source/html/HtmlApiExt.d.ts +2 -0
  9. package/build/dist/source/html/HtmlApiExt.js +11 -1
  10. package/build/dist/source/html/HtmlElements.js +174 -174
  11. package/build/dist/source/html/api.d.ts +1 -1
  12. package/build/dist/source/html/api.js +1 -1
  13. package/build/dist/source/html/sensors/BasePointerSensor.d.ts +5 -5
  14. package/build/dist/source/html/sensors/BasePointerSensor.js +11 -11
  15. package/build/dist/source/html/sensors/ButtonSensor.d.ts +6 -6
  16. package/build/dist/source/html/sensors/ButtonSensor.js +39 -48
  17. package/build/dist/source/html/sensors/DataForSensor.d.ts +1 -0
  18. package/build/dist/source/html/sensors/DataForSensor.js +1 -0
  19. package/build/dist/source/html/sensors/FocusSensor.d.ts +2 -2
  20. package/build/dist/source/html/sensors/FocusSensor.js +14 -17
  21. package/build/dist/source/html/sensors/HoverSensor.d.ts +15 -4
  22. package/build/dist/source/html/sensors/HoverSensor.js +65 -24
  23. package/build/dist/source/html/sensors/HtmlDragSensor.d.ts +2 -2
  24. package/build/dist/source/html/sensors/HtmlDragSensor.js +25 -34
  25. package/build/dist/source/html/sensors/HtmlElementSensor.d.ts +3 -3
  26. package/build/dist/source/html/sensors/HtmlElementSensor.js +7 -4
  27. package/build/dist/source/html/sensors/HtmlSensors.d.ts +23 -11
  28. package/build/dist/source/html/sensors/HtmlSensors.js +81 -35
  29. package/build/dist/source/html/sensors/KeyboardSensor.d.ts +17 -17
  30. package/build/dist/source/html/sensors/KeyboardSensor.js +42 -51
  31. package/build/dist/source/html/sensors/PointerSensor.d.ts +3 -2
  32. package/build/dist/source/html/sensors/PointerSensor.js +28 -38
  33. package/build/dist/source/html/sensors/ScrollSensor.d.ts +12 -0
  34. package/build/dist/source/html/sensors/ScrollSensor.js +62 -0
  35. package/build/dist/source/html/sensors/WheelSensor.d.ts +2 -2
  36. package/build/dist/source/html/sensors/WheelSensor.js +11 -20
  37. package/package.json +8 -8
  38. package/build/dist/source/html/ReactingFocuser.d.ts +0 -2
  39. 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
- constructor() {
22
- this.window = new WindowSensor();
23
- this.focus = new FocusSensor(this.window);
24
- this.hover = new HoverSensor();
25
- this.keyboard = new KeyboardSensor();
26
- this.wheel = new WheelSensor();
27
- this.resize = new ResizeSensor();
28
- this.htmlDrag = new HtmlDragSensor(this.focus, this.window);
29
- this.button = new ButtonSensor(this.focus, this.window);
30
- this.pointer = new PointerSensor(this.focus, this.window);
31
- }
32
- listen(element, enabled = true) {
33
- this.focus.listen(element, enabled);
34
- this.hover.listen(element, enabled);
35
- this.keyboard.listen(element, enabled);
36
- this.wheel.listen(element, enabled);
37
- this.htmlDrag.listen(element, enabled);
38
- this.button.listen(element, enabled);
39
- this.pointer.listen(element, enabled);
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
- 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
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(element: HTMLElement | undefined, enabled?: boolean): void;
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["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";
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.None;
36
+ this.modifiers = KeyboardModifiers.none;
37
37
  }
38
- listen(element, enabled = true) {
39
- const existing = this.sourceElement;
40
- if (element !== existing) {
41
- if (existing) {
42
- existing.removeEventListener("keydown", this.onKeyDown.bind(this), { capture: true });
43
- existing.removeEventListener("keyup", this.onKeyUp.bind(this), { capture: true });
44
- }
45
- this.sourceElement = element;
46
- if (element && enabled) {
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.None;
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.None;
83
+ let modifier = KeyboardModifiers.none;
87
84
  if (key === "Control")
88
- modifier = KeyboardModifiers.Ctrl;
85
+ modifier = KeyboardModifiers.ctrl;
89
86
  else if (key === "Shift")
90
- modifier = KeyboardModifiers.Shift;
87
+ modifier = KeyboardModifiers.shift;
91
88
  else if (key === "Alt")
92
- modifier = KeyboardModifiers.Alt;
89
+ modifier = KeyboardModifiers.alt;
93
90
  else if (key === "Meta")
94
- modifier = KeyboardModifiers.Meta;
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.None;
116
+ let modifiers = KeyboardModifiers.none;
126
117
  if (e.ctrlKey)
127
- modifiers |= KeyboardModifiers.Ctrl;
118
+ modifiers |= KeyboardModifiers.ctrl;
128
119
  else
129
- modifiers &= ~KeyboardModifiers.Ctrl;
120
+ modifiers &= ~KeyboardModifiers.ctrl;
130
121
  if (e.shiftKey)
131
- modifiers |= KeyboardModifiers.Shift;
122
+ modifiers |= KeyboardModifiers.shift;
132
123
  else
133
- modifiers &= ~KeyboardModifiers.Shift;
124
+ modifiers &= ~KeyboardModifiers.shift;
134
125
  if (e.altKey)
135
- modifiers |= KeyboardModifiers.Alt;
126
+ modifiers |= KeyboardModifiers.alt;
136
127
  else
137
- modifiers &= ~KeyboardModifiers.Alt;
128
+ modifiers &= ~KeyboardModifiers.alt;
138
129
  if (e.metaKey)
139
- modifiers |= KeyboardModifiers.Meta;
130
+ modifiers |= KeyboardModifiers.meta;
140
131
  else
141
- modifiers &= ~KeyboardModifiers.Meta;
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(element: HTMLElement | undefined, enabled?: boolean): void;
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.None;
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.None;
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.None;
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(element, enabled = true) {
55
- const existing = this.sourceElement;
56
- if (element !== existing) {
57
- if (existing) {
58
- existing.removeEventListener("pointerdown", this.onPointerDown.bind(this), { capture: true });
59
- existing.removeEventListener("pointermove", this.onPointerMove.bind(this), { capture: true });
60
- existing.removeEventListener("pointerup", this.onPointerUp.bind(this), { capture: true });
61
- existing.removeEventListener("lostpointercapture", this.onLostPointerCapture.bind(this), { capture: true });
62
- existing.removeEventListener("keydown", this.onKeyDown.bind(this), { capture: true });
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.Left || button === PointerButton.Right)) {
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 = (_a = findTargetElementData(targetPath, underPointer, SymDataForSensor, ["drag"], true).data) === null || _a === void 0 ? void 0 : _a.drag;
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.None;
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.None;
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.None;
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
- const clickable = (_a = findTargetElementData(targetPath, underPointer, SymDataForSensor, ["click"]).data) === null || _a === void 0 ? void 0 : _a.click;
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.CancelPrevious, logging: LoggingLevel.Off }),
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(element: HTMLElement | undefined, enabled?: boolean): void;
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(element, enabled = true) {
23
- const existing = this.sourceElement;
24
- if (element !== existing) {
25
- if (existing) {
26
- existing.removeEventListener("wheel", this.onWheel.bind(this), { capture: true });
27
- }
28
- this.sourceElement = element;
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.None;
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.CancelPrevious, logging: LoggingLevel.Off }),
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)