@lingxia/elements 0.10.0 → 0.11.1
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/dist/video.d.ts +2 -0
- package/dist/video.js +28 -0
- package/package.json +1 -1
- package/src/video.ts +25 -0
package/dist/video.d.ts
CHANGED
|
@@ -67,6 +67,8 @@ export declare class LxVideoElement extends HTMLElement {
|
|
|
67
67
|
private attrObserver?;
|
|
68
68
|
private resizeEventListener;
|
|
69
69
|
private iOSScrollEventListener;
|
|
70
|
+
private scrollSettleFrame;
|
|
71
|
+
private containerScrollListener;
|
|
70
72
|
private rawHandlers;
|
|
71
73
|
private _pageBindings;
|
|
72
74
|
private parseRotateValue;
|
package/dist/video.js
CHANGED
|
@@ -25,6 +25,21 @@ export class LxVideoElement extends HTMLElement {
|
|
|
25
25
|
this.iOSScrollEventListener = {
|
|
26
26
|
handleEvent: () => this.boundUpdatePosition(),
|
|
27
27
|
};
|
|
28
|
+
this.scrollSettleFrame = null;
|
|
29
|
+
// Scroll events do not bubble, so a plain window listener misses inner
|
|
30
|
+
// scroll containers; the capture phase sees them all. Any ancestor
|
|
31
|
+
// scrolling moves the element's document rect, so re-measure (coalesced
|
|
32
|
+
// to one update per frame; decide() dedups unchanged rects).
|
|
33
|
+
this.containerScrollListener = {
|
|
34
|
+
handleEvent: () => {
|
|
35
|
+
if (this.scrollSettleFrame !== null)
|
|
36
|
+
return;
|
|
37
|
+
this.scrollSettleFrame = requestAnimationFrame(() => {
|
|
38
|
+
this.scrollSettleFrame = null;
|
|
39
|
+
this.updatePosition();
|
|
40
|
+
});
|
|
41
|
+
},
|
|
42
|
+
};
|
|
28
43
|
this.rawHandlers = {};
|
|
29
44
|
this._pageBindings = {};
|
|
30
45
|
}
|
|
@@ -538,6 +553,12 @@ export class LxVideoElement extends HTMLElement {
|
|
|
538
553
|
if (isIOS()) {
|
|
539
554
|
window.addEventListener("scroll", this.iOSScrollEventListener, { passive: true });
|
|
540
555
|
}
|
|
556
|
+
else if (isWindows()) {
|
|
557
|
+
window.addEventListener("scroll", this.containerScrollListener, {
|
|
558
|
+
capture: true,
|
|
559
|
+
passive: true,
|
|
560
|
+
});
|
|
561
|
+
}
|
|
541
562
|
if (isAndroid()) {
|
|
542
563
|
this.removeLayoutInvalidationListener = addNativeComponentLayoutInvalidationListener(this.resizeEventListener);
|
|
543
564
|
}
|
|
@@ -550,9 +571,16 @@ export class LxVideoElement extends HTMLElement {
|
|
|
550
571
|
if (isIOS()) {
|
|
551
572
|
window.removeEventListener("scroll", this.iOSScrollEventListener);
|
|
552
573
|
}
|
|
574
|
+
else if (isWindows()) {
|
|
575
|
+
window.removeEventListener("scroll", this.containerScrollListener, { capture: true });
|
|
576
|
+
}
|
|
553
577
|
(_a = this.removeLayoutInvalidationListener) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
554
578
|
this.removeLayoutInvalidationListener = undefined;
|
|
555
579
|
this.stopSizeObserver();
|
|
580
|
+
if (this.scrollSettleFrame !== null) {
|
|
581
|
+
cancelAnimationFrame(this.scrollSettleFrame);
|
|
582
|
+
this.scrollSettleFrame = null;
|
|
583
|
+
}
|
|
556
584
|
if (this.winSettleFrame !== null) {
|
|
557
585
|
cancelAnimationFrame(this.winSettleFrame);
|
|
558
586
|
this.winSettleFrame = null;
|
package/package.json
CHANGED
package/src/video.ts
CHANGED
|
@@ -106,6 +106,20 @@ export class LxVideoElement extends HTMLElement {
|
|
|
106
106
|
private iOSScrollEventListener: EventListenerObject = {
|
|
107
107
|
handleEvent: () => this.boundUpdatePosition(),
|
|
108
108
|
};
|
|
109
|
+
private scrollSettleFrame: number | null = null;
|
|
110
|
+
// Scroll events do not bubble, so a plain window listener misses inner
|
|
111
|
+
// scroll containers; the capture phase sees them all. Any ancestor
|
|
112
|
+
// scrolling moves the element's document rect, so re-measure (coalesced
|
|
113
|
+
// to one update per frame; decide() dedups unchanged rects).
|
|
114
|
+
private containerScrollListener: EventListenerObject = {
|
|
115
|
+
handleEvent: () => {
|
|
116
|
+
if (this.scrollSettleFrame !== null) return;
|
|
117
|
+
this.scrollSettleFrame = requestAnimationFrame(() => {
|
|
118
|
+
this.scrollSettleFrame = null;
|
|
119
|
+
this.updatePosition();
|
|
120
|
+
});
|
|
121
|
+
},
|
|
122
|
+
};
|
|
109
123
|
private rawHandlers: Record<string, EventListenerOrEventListenerObject> = {};
|
|
110
124
|
private _pageBindings: Record<string, string> = {};
|
|
111
125
|
|
|
@@ -641,6 +655,11 @@ export class LxVideoElement extends HTMLElement {
|
|
|
641
655
|
window.addEventListener("resize", this.resizeEventListener);
|
|
642
656
|
if (isIOS()) {
|
|
643
657
|
window.addEventListener("scroll", this.iOSScrollEventListener, { passive: true });
|
|
658
|
+
} else if (isWindows()) {
|
|
659
|
+
window.addEventListener("scroll", this.containerScrollListener, {
|
|
660
|
+
capture: true,
|
|
661
|
+
passive: true,
|
|
662
|
+
});
|
|
644
663
|
}
|
|
645
664
|
if (isAndroid()) {
|
|
646
665
|
this.removeLayoutInvalidationListener = addNativeComponentLayoutInvalidationListener(this.resizeEventListener);
|
|
@@ -653,10 +672,16 @@ export class LxVideoElement extends HTMLElement {
|
|
|
653
672
|
window.removeEventListener("resize", this.resizeEventListener);
|
|
654
673
|
if (isIOS()) {
|
|
655
674
|
window.removeEventListener("scroll", this.iOSScrollEventListener);
|
|
675
|
+
} else if (isWindows()) {
|
|
676
|
+
window.removeEventListener("scroll", this.containerScrollListener, { capture: true });
|
|
656
677
|
}
|
|
657
678
|
this.removeLayoutInvalidationListener?.();
|
|
658
679
|
this.removeLayoutInvalidationListener = undefined;
|
|
659
680
|
this.stopSizeObserver();
|
|
681
|
+
if (this.scrollSettleFrame !== null) {
|
|
682
|
+
cancelAnimationFrame(this.scrollSettleFrame);
|
|
683
|
+
this.scrollSettleFrame = null;
|
|
684
|
+
}
|
|
660
685
|
if (this.winSettleFrame !== null) {
|
|
661
686
|
cancelAnimationFrame(this.winSettleFrame);
|
|
662
687
|
this.winSettleFrame = null;
|