@lynx-js/web-elements-canary 0.11.0 → 0.11.1-canary-20260127-1fa1ddc7
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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @lynx-js/web-elements
|
|
2
2
|
|
|
3
|
+
## 0.11.1-canary-20260127122712-1fa1ddc77447704d6865509a884aa71ea72cd56e
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- feat: add wheel event handling and corresponding tests for x-foldview-ng ([#2145](https://github.com/lynx-family/lynx-stack/pull/2145))
|
|
8
|
+
|
|
3
9
|
## 0.11.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
|
@@ -11,11 +17,11 @@
|
|
|
11
17
|
Now we integrated the `LinearCompat` into @lynx-js/web-elements. Developers can safely remove the following imports:
|
|
12
18
|
|
|
13
19
|
```js
|
|
14
|
-
import
|
|
20
|
+
import "@lynx-js/web-elements/compat/LinearContainer";
|
|
15
21
|
```
|
|
16
22
|
|
|
17
23
|
```js
|
|
18
|
-
import
|
|
24
|
+
import "@lynx-js/web-elements-compat/LinearContainer";
|
|
19
25
|
```
|
|
20
26
|
|
|
21
27
|
### Patch Changes
|
|
@@ -41,15 +47,15 @@
|
|
|
41
47
|
### Before
|
|
42
48
|
|
|
43
49
|
```js
|
|
44
|
-
import
|
|
45
|
-
import
|
|
50
|
+
import "@lynx-js/web-elements-template";
|
|
51
|
+
import "@lynx-js/web-elements-compat/LinearContainer";
|
|
46
52
|
```
|
|
47
53
|
|
|
48
54
|
### After
|
|
49
55
|
|
|
50
56
|
```js
|
|
51
|
-
import
|
|
52
|
-
import
|
|
57
|
+
import "@lynx-js/web-elements/html-templates";
|
|
58
|
+
import "@lynx-js/web-elements/compat/LinearContainer";
|
|
53
59
|
```
|
|
54
60
|
|
|
55
61
|
### Patch Changes
|
|
@@ -734,8 +740,8 @@
|
|
|
734
740
|
For compating usage, `@lynx-js/web-elements-compat/LinearContainer` is provided.
|
|
735
741
|
|
|
736
742
|
```javascript
|
|
737
|
-
import
|
|
738
|
-
import
|
|
743
|
+
import "@lynx-js/web-elements-compat/LinearContainer";
|
|
744
|
+
import "@lynx-js/web-elements/all";
|
|
739
745
|
```
|
|
740
746
|
|
|
741
747
|
- f8d1d98: break: rename the `blur` and `focus` event to `lynxblur` and `lynxfocus` for x-input element
|
|
@@ -757,11 +763,11 @@
|
|
|
757
763
|
There is also a simple way to use this feature
|
|
758
764
|
|
|
759
765
|
```javascript
|
|
760
|
-
import { LynxCard } from
|
|
761
|
-
import { loadElement } from
|
|
762
|
-
import
|
|
763
|
-
import
|
|
764
|
-
import
|
|
766
|
+
import { LynxCard } from "@lynx-js/web-core";
|
|
767
|
+
import { loadElement } from "@lynx-js/web-elements/lazy";
|
|
768
|
+
import "@lynx-js/web-elements/index.css";
|
|
769
|
+
import "@lynx-js/web-core/index.css";
|
|
770
|
+
import "./index.css";
|
|
765
771
|
|
|
766
772
|
const lynxcard = new LynxCard({
|
|
767
773
|
...beforeConfigs,
|
|
@@ -12,7 +12,7 @@ export class XFoldviewSlotNgTouchEventsHandler {
|
|
|
12
12
|
static observedAttributes = [];
|
|
13
13
|
constructor(dom) {
|
|
14
14
|
this.#dom = dom;
|
|
15
|
-
this.#dom.addEventListener('touchmove', this.#
|
|
15
|
+
this.#dom.addEventListener('touchmove', this.#handleTouch, {
|
|
16
16
|
passive: false,
|
|
17
17
|
});
|
|
18
18
|
this.#dom.addEventListener('touchstart', this.#touchStart, {
|
|
@@ -21,6 +21,9 @@ export class XFoldviewSlotNgTouchEventsHandler {
|
|
|
21
21
|
this.#dom.addEventListener('touchend', this.#touchEnd, {
|
|
22
22
|
passive: true,
|
|
23
23
|
});
|
|
24
|
+
this.#dom.addEventListener('wheel', this.#handleWheel, {
|
|
25
|
+
passive: false,
|
|
26
|
+
});
|
|
24
27
|
}
|
|
25
28
|
#getTheMostScrollableKid(delta) {
|
|
26
29
|
const scrollableKid = this.#elements?.find((element) => {
|
|
@@ -42,8 +45,11 @@ export class XFoldviewSlotNgTouchEventsHandler {
|
|
|
42
45
|
this.#childrenElemsntsScrollTop.set(scrollableKid, targetKidScrollDistance);
|
|
43
46
|
scrollableKid.scrollTop = targetKidScrollDistance;
|
|
44
47
|
}
|
|
45
|
-
#
|
|
48
|
+
#handleTouch = (event) => {
|
|
46
49
|
const parentElement = this.#getParentElement();
|
|
50
|
+
if (!parentElement) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
47
53
|
const touch = event.touches.item(0);
|
|
48
54
|
const { pageY, pageX } = touch;
|
|
49
55
|
const deltaY = this.#previousPageY - pageY;
|
|
@@ -54,33 +60,34 @@ export class XFoldviewSlotNgTouchEventsHandler {
|
|
|
54
60
|
if (this.#scrollingVertically === false) {
|
|
55
61
|
return;
|
|
56
62
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (event.cancelable) {
|
|
60
|
-
event.preventDefault();
|
|
61
|
-
}
|
|
62
|
-
if ((parentElement[isHeaderShowing] && deltaY > 0
|
|
63
|
-
|| (deltaY < 0 && !scrollableKidY))
|
|
64
|
-
// deltaY > 0: swipe up (folding header)
|
|
65
|
-
// scroll the foldview if its scrollable
|
|
66
|
-
|| (!parentElement[isHeaderShowing] && !scrollableKidY)
|
|
67
|
-
// all sub doms are scrolled
|
|
68
|
-
) {
|
|
69
|
-
parentElement.scrollBy({
|
|
70
|
-
top: deltaY,
|
|
71
|
-
behavior: 'smooth',
|
|
72
|
-
});
|
|
73
|
-
this.#parentScrollTop += deltaY;
|
|
74
|
-
parentElement.scrollTop = this.#parentScrollTop;
|
|
75
|
-
this.#currentScrollingElement = parentElement;
|
|
76
|
-
}
|
|
77
|
-
else if (scrollableKidY) {
|
|
78
|
-
this.#currentScrollingElement = scrollableKidY;
|
|
79
|
-
this.#scrollKid(scrollableKidY, deltaY);
|
|
80
|
-
}
|
|
63
|
+
if (event.cancelable) {
|
|
64
|
+
event.preventDefault();
|
|
81
65
|
}
|
|
66
|
+
this.#handleScrollDelta(deltaY, parentElement);
|
|
82
67
|
this.#previousPageY = pageY;
|
|
83
|
-
|
|
68
|
+
};
|
|
69
|
+
#handleWheel = (event) => {
|
|
70
|
+
const parentElement = this.#getParentElement();
|
|
71
|
+
if (!parentElement) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (Math.abs(event.deltaY) <= Math.abs(event.deltaX)) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const pathElements = event.composedPath().filter((element) => element instanceof Element && this.#dom.contains(element));
|
|
78
|
+
const { clientX, clientY } = event;
|
|
79
|
+
const pointElements = document.elementsFromPoint(clientX, clientY).filter(e => this.#dom.contains(e));
|
|
80
|
+
this.#elements = [...new Set([...pathElements, ...pointElements])];
|
|
81
|
+
this.#parentScrollTop = parentElement.scrollTop;
|
|
82
|
+
if (this.#elements) {
|
|
83
|
+
for (const element of this.#elements) {
|
|
84
|
+
this.#childrenElemsntsScrollTop.set(element, element.scrollTop);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (event.cancelable) {
|
|
88
|
+
event.preventDefault();
|
|
89
|
+
}
|
|
90
|
+
this.#handleScrollDelta(event.deltaY, parentElement);
|
|
84
91
|
};
|
|
85
92
|
#getParentElement() {
|
|
86
93
|
const parentElement = this.#dom.parentElement;
|
|
@@ -114,5 +121,28 @@ export class XFoldviewSlotNgTouchEventsHandler {
|
|
|
114
121
|
});
|
|
115
122
|
}
|
|
116
123
|
};
|
|
124
|
+
#handleScrollDelta(deltaY, parentElement) {
|
|
125
|
+
const scrollableKidY = this.#getTheMostScrollableKid(deltaY);
|
|
126
|
+
if ((parentElement[isHeaderShowing] && deltaY > 0
|
|
127
|
+
|| (deltaY < 0 && !scrollableKidY))
|
|
128
|
+
// deltaY > 0: swipe up (folding header)
|
|
129
|
+
// scroll the foldview if its scrollable
|
|
130
|
+
|| (!parentElement[isHeaderShowing] && !scrollableKidY)
|
|
131
|
+
// all sub doms are scrolled
|
|
132
|
+
) {
|
|
133
|
+
parentElement.scrollBy({
|
|
134
|
+
top: deltaY,
|
|
135
|
+
behavior: 'smooth',
|
|
136
|
+
});
|
|
137
|
+
this.#parentScrollTop += deltaY;
|
|
138
|
+
parentElement.scrollTop = this.#parentScrollTop;
|
|
139
|
+
this.#currentScrollingElement = parentElement;
|
|
140
|
+
}
|
|
141
|
+
else if (scrollableKidY) {
|
|
142
|
+
this.#currentScrollingElement = scrollableKidY;
|
|
143
|
+
this.#scrollKid(scrollableKidY, deltaY);
|
|
144
|
+
}
|
|
145
|
+
this.#deltaY = deltaY;
|
|
146
|
+
}
|
|
117
147
|
}
|
|
118
148
|
//# sourceMappingURL=XFoldviewSlotNgTouchEventsHandler.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/web-elements-canary",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.1-canary-20260127-1fa1ddc7",
|
|
4
4
|
"private": false,
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -128,7 +128,7 @@
|
|
|
128
128
|
],
|
|
129
129
|
"devDependencies": {
|
|
130
130
|
"@playwright/test": "^1.57.0",
|
|
131
|
-
"@rsbuild/core": "1.7.
|
|
131
|
+
"@rsbuild/core": "1.7.2",
|
|
132
132
|
"@rsbuild/plugin-source-build": "^1.0.3",
|
|
133
133
|
"nyc": "^17.1.0",
|
|
134
134
|
"tslib": "^2.8.1",
|