@lynx-js/web-elements 0.2.4
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 +323 -0
- package/LICENSE.txt +202 -0
- package/Notice.txt +1 -0
- package/README.md +47 -0
- package/dist/LynxWrapper/LynxWrapper.d.ts +2 -0
- package/dist/LynxWrapper/LynxWrapper.js +27 -0
- package/dist/LynxWrapper/index.d.ts +1 -0
- package/dist/LynxWrapper/index.js +2 -0
- package/dist/ScrollView/FadeEdgeLengthAttribute.d.ts +10 -0
- package/dist/ScrollView/FadeEdgeLengthAttribute.js +43 -0
- package/dist/ScrollView/ScrollAttributes.d.ts +8 -0
- package/dist/ScrollView/ScrollAttributes.js +83 -0
- package/dist/ScrollView/ScrollIntoView.d.ts +9 -0
- package/dist/ScrollView/ScrollIntoView.js +71 -0
- package/dist/ScrollView/ScrollView.d.ts +31 -0
- package/dist/ScrollView/ScrollView.js +185 -0
- package/dist/ScrollView/ScrollViewEvents.d.ts +9 -0
- package/dist/ScrollView/ScrollViewEvents.js +146 -0
- package/dist/ScrollView/index.d.ts +1 -0
- package/dist/ScrollView/index.js +2 -0
- package/dist/XAudioTT/XAudioAttribute.d.ts +7 -0
- package/dist/XAudioTT/XAudioAttribute.js +93 -0
- package/dist/XAudioTT/XAudioEvents.d.ts +8 -0
- package/dist/XAudioTT/XAudioEvents.js +116 -0
- package/dist/XAudioTT/XAudioTT.d.ts +46 -0
- package/dist/XAudioTT/XAudioTT.js +183 -0
- package/dist/XAudioTT/index.d.ts +1 -0
- package/dist/XAudioTT/index.js +2 -0
- package/dist/XAudioTT/utils.d.ts +19 -0
- package/dist/XAudioTT/utils.js +66 -0
- package/dist/XCanvas/CanvasAttributes.d.ts +12 -0
- package/dist/XCanvas/CanvasAttributes.js +78 -0
- package/dist/XCanvas/XCanvas.d.ts +5 -0
- package/dist/XCanvas/XCanvas.js +32 -0
- package/dist/XCanvas/index.d.ts +1 -0
- package/dist/XCanvas/index.js +2 -0
- package/dist/XFoldViewNg/XFoldviewHeaderNg.d.ts +2 -0
- package/dist/XFoldViewNg/XFoldviewHeaderNg.js +32 -0
- package/dist/XFoldViewNg/XFoldviewHeaderNgFeatures.d.ts +9 -0
- package/dist/XFoldViewNg/XFoldviewHeaderNgFeatures.js +32 -0
- package/dist/XFoldViewNg/XFoldviewNg.d.ts +11 -0
- package/dist/XFoldViewNg/XFoldviewNg.js +52 -0
- package/dist/XFoldViewNg/XFoldviewNgEvents.d.ts +7 -0
- package/dist/XFoldViewNg/XFoldviewNgEvents.js +55 -0
- package/dist/XFoldViewNg/XFoldviewSlotDragNg.d.ts +2 -0
- package/dist/XFoldViewNg/XFoldviewSlotDragNg.js +30 -0
- package/dist/XFoldViewNg/XFoldviewSlotNg.d.ts +2 -0
- package/dist/XFoldViewNg/XFoldviewSlotNg.js +32 -0
- package/dist/XFoldViewNg/XFoldviewSlotNgTouchEventsHandler.d.ts +7 -0
- package/dist/XFoldViewNg/XFoldviewSlotNgTouchEventsHandler.js +105 -0
- package/dist/XFoldViewNg/XFoldviewToolbarNg.d.ts +2 -0
- package/dist/XFoldViewNg/XFoldviewToolbarNg.js +30 -0
- package/dist/XFoldViewNg/index.d.ts +5 -0
- package/dist/XFoldViewNg/index.js +6 -0
- package/dist/XImage/DropShadow.d.ts +6 -0
- package/dist/XImage/DropShadow.js +30 -0
- package/dist/XImage/FilterImage.d.ts +2 -0
- package/dist/XImage/FilterImage.js +31 -0
- package/dist/XImage/ImageEvents.d.ts +6 -0
- package/dist/XImage/ImageEvents.js +68 -0
- package/dist/XImage/ImageSrc.d.ts +7 -0
- package/dist/XImage/ImageSrc.js +61 -0
- package/dist/XImage/XImage.d.ts +2 -0
- package/dist/XImage/XImage.js +30 -0
- package/dist/XImage/index.d.ts +2 -0
- package/dist/XImage/index.js +3 -0
- package/dist/XInput/InputBaseAttributes.d.ts +9 -0
- package/dist/XInput/InputBaseAttributes.js +99 -0
- package/dist/XInput/Placeholder.d.ts +6 -0
- package/dist/XInput/Placeholder.js +60 -0
- package/dist/XInput/XInput.d.ts +28 -0
- package/dist/XInput/XInput.js +129 -0
- package/dist/XInput/XInputAttribute.d.ts +9 -0
- package/dist/XInput/XInputAttribute.js +52 -0
- package/dist/XInput/XInputEvents.d.ts +6 -0
- package/dist/XInput/XInputEvents.js +111 -0
- package/dist/XInput/index.d.ts +1 -0
- package/dist/XInput/index.js +2 -0
- package/dist/XList/ListItem.d.ts +2 -0
- package/dist/XList/ListItem.js +28 -0
- package/dist/XList/XList.d.ts +52 -0
- package/dist/XList/XList.js +257 -0
- package/dist/XList/XListAttributes.d.ts +8 -0
- package/dist/XList/XListAttributes.js +50 -0
- package/dist/XList/XListEvents.d.ts +7 -0
- package/dist/XList/XListEvents.js +356 -0
- package/dist/XList/index.d.ts +2 -0
- package/dist/XList/index.js +3 -0
- package/dist/XOverlayNg/XOverlayAttributes.d.ts +8 -0
- package/dist/XOverlayNg/XOverlayAttributes.js +80 -0
- package/dist/XOverlayNg/XOverlayNg.d.ts +2 -0
- package/dist/XOverlayNg/XOverlayNg.js +45 -0
- package/dist/XOverlayNg/index.d.ts +1 -0
- package/dist/XOverlayNg/index.js +2 -0
- package/dist/XRefreshView/XRefreshFooter.d.ts +3 -0
- package/dist/XRefreshView/XRefreshFooter.js +35 -0
- package/dist/XRefreshView/XRefreshHeader.d.ts +3 -0
- package/dist/XRefreshView/XRefreshHeader.js +35 -0
- package/dist/XRefreshView/XRefreshSubElementIntersectionObserver.d.ts +16 -0
- package/dist/XRefreshView/XRefreshSubElementIntersectionObserver.js +52 -0
- package/dist/XRefreshView/XRefreshView.d.ts +13 -0
- package/dist/XRefreshView/XRefreshView.js +125 -0
- package/dist/XRefreshView/XRefreshViewEventsEmitter.d.ts +8 -0
- package/dist/XRefreshView/XRefreshViewEventsEmitter.js +246 -0
- package/dist/XRefreshView/index.d.ts +3 -0
- package/dist/XRefreshView/index.js +4 -0
- package/dist/XSvg/XSvg.d.ts +8 -0
- package/dist/XSvg/XSvg.js +80 -0
- package/dist/XSvg/index.d.ts +1 -0
- package/dist/XSvg/index.js +2 -0
- package/dist/XSwiper/SwiperItem.d.ts +2 -0
- package/dist/XSwiper/SwiperItem.js +28 -0
- package/dist/XSwiper/XSwiper.d.ts +14 -0
- package/dist/XSwiper/XSwiper.js +231 -0
- package/dist/XSwiper/XSwiperAutoScroll.d.ts +8 -0
- package/dist/XSwiper/XSwiperAutoScroll.js +63 -0
- package/dist/XSwiper/XSwiperCircular.d.ts +8 -0
- package/dist/XSwiper/XSwiperCircular.js +191 -0
- package/dist/XSwiper/XSwiperEvents.d.ts +8 -0
- package/dist/XSwiper/XSwiperEvents.js +144 -0
- package/dist/XSwiper/XSwiperIndicator.d.ts +9 -0
- package/dist/XSwiper/XSwiperIndicator.js +118 -0
- package/dist/XSwiper/index.d.ts +2 -0
- package/dist/XSwiper/index.js +3 -0
- package/dist/XText/InlineImage.d.ts +11 -0
- package/dist/XText/InlineImage.js +56 -0
- package/dist/XText/InlineText.d.ts +5 -0
- package/dist/XText/InlineText.js +30 -0
- package/dist/XText/InlineTruncation.d.ts +5 -0
- package/dist/XText/InlineTruncation.js +42 -0
- package/dist/XText/RawText.d.ts +7 -0
- package/dist/XText/RawText.js +54 -0
- package/dist/XText/XText.d.ts +5 -0
- package/dist/XText/XText.js +49 -0
- package/dist/XText/XTextTruncation.d.ts +11 -0
- package/dist/XText/XTextTruncation.js +604 -0
- package/dist/XText/index.d.ts +5 -0
- package/dist/XText/index.js +6 -0
- package/dist/XTextarea/Placeholder.d.ts +7 -0
- package/dist/XTextarea/Placeholder.js +59 -0
- package/dist/XTextarea/TextareaBaseAttributes.d.ts +6 -0
- package/dist/XTextarea/TextareaBaseAttributes.js +70 -0
- package/dist/XTextarea/XTextarea.d.ts +21 -0
- package/dist/XTextarea/XTextarea.js +101 -0
- package/dist/XTextarea/XTextareaAttributes.d.ts +6 -0
- package/dist/XTextarea/XTextareaAttributes.js +81 -0
- package/dist/XTextarea/XTextareaEvents.d.ts +6 -0
- package/dist/XTextarea/XTextareaEvents.js +111 -0
- package/dist/XTextarea/index.d.ts +1 -0
- package/dist/XTextarea/index.js +2 -0
- package/dist/XView/BlurRadius.d.ts +7 -0
- package/dist/XView/BlurRadius.js +38 -0
- package/dist/XView/XBlurView.d.ts +2 -0
- package/dist/XView/XBlurView.js +29 -0
- package/dist/XView/XView.d.ts +4 -0
- package/dist/XView/XView.js +45 -0
- package/dist/XView/index.d.ts +2 -0
- package/dist/XView/index.js +3 -0
- package/dist/XViewpagerNg/XViewpagerItemNg.d.ts +2 -0
- package/dist/XViewpagerNg/XViewpagerItemNg.js +30 -0
- package/dist/XViewpagerNg/XViewpagerNg.d.ts +10 -0
- package/dist/XViewpagerNg/XViewpagerNg.js +98 -0
- package/dist/XViewpagerNg/XViewpagerNgEvents.d.ts +9 -0
- package/dist/XViewpagerNg/XViewpagerNgEvents.js +118 -0
- package/dist/XViewpagerNg/index.d.ts +2 -0
- package/dist/XViewpagerNg/index.js +3 -0
- package/dist/all.d.ts +16 -0
- package/dist/all.js +17 -0
- package/dist/common/Exposure.d.ts +28 -0
- package/dist/common/Exposure.js +193 -0
- package/dist/common/bindToIntersectionObserver.d.ts +1 -0
- package/dist/common/bindToIntersectionObserver.js +23 -0
- package/dist/common/commonEventInitConfiguration.d.ts +5 -0
- package/dist/common/commonEventInitConfiguration.js +9 -0
- package/dist/common/constants.d.ts +4 -0
- package/dist/common/constants.js +14 -0
- package/dist/common/convertLengthToPx.d.ts +1 -0
- package/dist/common/convertLengthToPx.js +25 -0
- package/dist/common/renameEvent.d.ts +1 -0
- package/dist/common/renameEvent.js +6 -0
- package/dist/common/throttle.d.ts +4 -0
- package/dist/common/throttle.js +40 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +8 -0
- package/dist/lazy.d.ts +1 -0
- package/dist/lazy.js +106 -0
- package/index.css +19 -0
- package/package.json +110 -0
- package/src/LynxWrapper/lynx-wrapper.css +12 -0
- package/src/ScrollView/scroll-view.css +121 -0
- package/src/XAudioTT/x-audio-tt.css +3 -0
- package/src/XCanvas/x-canvas.css +16 -0
- package/src/XFoldViewNg/x-foldview-ng.css +80 -0
- package/src/XImage/x-image.css +82 -0
- package/src/XInput/x-input.css +48 -0
- package/src/XList/x-list.css +147 -0
- package/src/XOverlayNg/x-overlay-ng.css +56 -0
- package/src/XRefreshView/x-refresh-view.css +61 -0
- package/src/XSvg/x-svg.css +10 -0
- package/src/XSwiper/x-swiper.css +319 -0
- package/src/XText/x-text.css +272 -0
- package/src/XTextarea/x-textarea.css +49 -0
- package/src/XViewpagerNg/x-viewpager-ng.css +68 -0
- package/src/common-css/linear.css +386 -0
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { __esDecorate, __runInitializers } from "tslib";
|
|
2
|
+
/*
|
|
3
|
+
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
4
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
5
|
+
// LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import { Component, genDomGetter, html } from '@lynx-js/web-elements-reactive';
|
|
8
|
+
import { XSwipeEvents } from './XSwiperEvents.js';
|
|
9
|
+
import { XSwiperAutoScroll } from './XSwiperAutoScroll.js';
|
|
10
|
+
import { XSwiperCircular } from './XSwiperCircular.js';
|
|
11
|
+
import { XSwiperIndicator } from './XSwiperIndicator.js';
|
|
12
|
+
import { LynxExposure } from '../common/Exposure.js';
|
|
13
|
+
import { scrollContainerDom } from '../common/constants.js';
|
|
14
|
+
let XSwiper = (() => {
|
|
15
|
+
let _classDecorators = [Component('x-swiper', [
|
|
16
|
+
LynxExposure,
|
|
17
|
+
XSwiperIndicator,
|
|
18
|
+
XSwipeEvents,
|
|
19
|
+
XSwiperCircular,
|
|
20
|
+
XSwiperAutoScroll,
|
|
21
|
+
], html ` <style>
|
|
22
|
+
#bounce-padding {
|
|
23
|
+
display: none;
|
|
24
|
+
flex: 0 0 0;
|
|
25
|
+
align-self: stretch;
|
|
26
|
+
scroll-snap-align: none;
|
|
27
|
+
flex-basis: 100%;
|
|
28
|
+
}
|
|
29
|
+
#content {
|
|
30
|
+
position: relative;
|
|
31
|
+
display: flex;
|
|
32
|
+
flex: 0 0 100%;
|
|
33
|
+
flex-direction: inherit;
|
|
34
|
+
flex-wrap: inherit;
|
|
35
|
+
align-self: stretch;
|
|
36
|
+
justify-content: inherit;
|
|
37
|
+
align-items: inherit;
|
|
38
|
+
overflow: inherit;
|
|
39
|
+
scrollbar-width: none;
|
|
40
|
+
scroll-snap-align: start;
|
|
41
|
+
scroll-snap-type: inherit;
|
|
42
|
+
}
|
|
43
|
+
div::-webkit-scrollbar {
|
|
44
|
+
display: none;
|
|
45
|
+
}
|
|
46
|
+
#indicator-container {
|
|
47
|
+
display: none;
|
|
48
|
+
}
|
|
49
|
+
@keyframes indicator-dot {
|
|
50
|
+
30%,
|
|
51
|
+
70% {
|
|
52
|
+
background-color: var(--indicator-color);
|
|
53
|
+
}
|
|
54
|
+
31%,
|
|
55
|
+
69% {
|
|
56
|
+
background-color: var(--indicator-active-color);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
</style>
|
|
60
|
+
<style id="indicator-style"></style>
|
|
61
|
+
<div id="bounce-padding" part="bounce-padding"></div>
|
|
62
|
+
<div id="indicator-container" part="indicator-container"></div>
|
|
63
|
+
<div id="content" part="content">
|
|
64
|
+
<slot part="slot-start" name="circular-start" id="circular-start"></slot>
|
|
65
|
+
<slot part="slot"></slot>
|
|
66
|
+
<slot part="slot-end" name="circular-end" id="circular-end"></slot>
|
|
67
|
+
</div>`)];
|
|
68
|
+
let _classDescriptor;
|
|
69
|
+
let _classExtraInitializers = [];
|
|
70
|
+
let _classThis;
|
|
71
|
+
let _classSuper = HTMLElement;
|
|
72
|
+
var XSwiper = class extends _classSuper {
|
|
73
|
+
static { _classThis = this; }
|
|
74
|
+
static {
|
|
75
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
76
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
77
|
+
XSwiper = _classThis = _classDescriptor.value;
|
|
78
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
79
|
+
}
|
|
80
|
+
static notToFilterFalseAttributes = new Set([
|
|
81
|
+
'smooth-scroll',
|
|
82
|
+
'indicator-dots',
|
|
83
|
+
]);
|
|
84
|
+
#getContentContainer = genDomGetter(() => this.shadowRoot, '#content').bind(this);
|
|
85
|
+
#getNeatestElementIndexAndDistanceToMid() {
|
|
86
|
+
let current = 0;
|
|
87
|
+
let minDistanceToMid = Number.MAX_SAFE_INTEGER;
|
|
88
|
+
let minOffsetToMid = 0;
|
|
89
|
+
if (this.childElementCount > 0) {
|
|
90
|
+
const contentContainer = this.#getContentContainer();
|
|
91
|
+
const isVertical = this.isVertical;
|
|
92
|
+
const numberOfChildren = this.childElementCount;
|
|
93
|
+
/* already scrolled distance */
|
|
94
|
+
const currentScrollDistance = isVertical
|
|
95
|
+
? contentContainer.scrollTop
|
|
96
|
+
: contentContainer.scrollLeft;
|
|
97
|
+
const pageLength = isVertical
|
|
98
|
+
? contentContainer.clientHeight
|
|
99
|
+
: contentContainer.clientWidth;
|
|
100
|
+
const itemLength = isVertical
|
|
101
|
+
? this.firstElementChild.offsetHeight
|
|
102
|
+
: this.firstElementChild.offsetWidth;
|
|
103
|
+
/**
|
|
104
|
+
* ============================
|
|
105
|
+
* | |
|
|
106
|
+
* | |
|
|
107
|
+
* | <-> scroll container |
|
|
108
|
+
* | |
|
|
109
|
+
* | |
|
|
110
|
+
* ============================
|
|
111
|
+
* ^___ mid
|
|
112
|
+
*/
|
|
113
|
+
// mode carousel width is 80% of pageLength
|
|
114
|
+
const midWidth = this.getAttribute('mode') === 'carousel'
|
|
115
|
+
? (pageLength * 0.8) / 2
|
|
116
|
+
: pageLength / 2;
|
|
117
|
+
const midOffset = currentScrollDistance + midWidth;
|
|
118
|
+
for (let ii = 0; ii < numberOfChildren; ii++) {
|
|
119
|
+
const swiperItem = this.children[ii];
|
|
120
|
+
if (swiperItem) {
|
|
121
|
+
const scrollOffset = (isVertical ? swiperItem.offsetTop : swiperItem.offsetLeft)
|
|
122
|
+
+ itemLength / 2;
|
|
123
|
+
const offsetToMid = scrollOffset - midOffset;
|
|
124
|
+
const distanceToMid = Math.abs(offsetToMid);
|
|
125
|
+
if (distanceToMid < minDistanceToMid) {
|
|
126
|
+
current = ii;
|
|
127
|
+
minDistanceToMid = distanceToMid;
|
|
128
|
+
minOffsetToMid = offsetToMid;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
current,
|
|
135
|
+
minDistanceToMid,
|
|
136
|
+
minOffsetToMid,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
get current() {
|
|
140
|
+
return this.#getNeatestElementIndexAndDistanceToMid().current;
|
|
141
|
+
}
|
|
142
|
+
set current(newval) {
|
|
143
|
+
// When current is specified and current is updated in bindchange, there is no need to respond to the update of current
|
|
144
|
+
if (this.current === newval) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
const smooth = this.getAttribute('smooth-scroll') === null; // smooth-scroll default true, it is set to be false
|
|
148
|
+
this.#scrollToIndex(newval, smooth ? 'smooth' : 'instant');
|
|
149
|
+
}
|
|
150
|
+
#scrollToIndex(index, behavior) {
|
|
151
|
+
const target = this.children.item(index);
|
|
152
|
+
if (target) {
|
|
153
|
+
const isVertical = this.isVertical;
|
|
154
|
+
let offset = 0;
|
|
155
|
+
// flat-coverflow mode, should scroll to the mid, 20% of left, 1/3 of width.
|
|
156
|
+
if (this.getAttribute('mode') === 'flat-coverflow') {
|
|
157
|
+
if (isVertical) {
|
|
158
|
+
offset = target.offsetTop - target.offsetHeight / 3;
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
offset = target.offsetLeft - target.offsetWidth / 3;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
if (isVertical) {
|
|
166
|
+
offset = target.offsetTop;
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
offset = target.offsetLeft;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
this.#getContentContainer().scrollTo({
|
|
173
|
+
left: isVertical ? 0 : offset,
|
|
174
|
+
top: isVertical ? offset : 0,
|
|
175
|
+
behavior,
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
get snapDistance() {
|
|
180
|
+
return this.#getNeatestElementIndexAndDistanceToMid().minOffsetToMid;
|
|
181
|
+
}
|
|
182
|
+
get isVertical() {
|
|
183
|
+
return this.getAttribute('vertical') !== null;
|
|
184
|
+
}
|
|
185
|
+
get circularPlay() {
|
|
186
|
+
return this.getAttribute('circular') !== null;
|
|
187
|
+
}
|
|
188
|
+
scrollToNext() {
|
|
189
|
+
const current = this.current;
|
|
190
|
+
const count = this.childElementCount;
|
|
191
|
+
if (current === count - 1) {
|
|
192
|
+
const circularPlay = this.circularPlay;
|
|
193
|
+
if (circularPlay) {
|
|
194
|
+
this.current = 0;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
this.current += 1;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
scrollToPrevious() {
|
|
202
|
+
const current = this.current;
|
|
203
|
+
const count = this.childElementCount;
|
|
204
|
+
if (current === 0) {
|
|
205
|
+
const circularPlay = this.circularPlay;
|
|
206
|
+
if (circularPlay) {
|
|
207
|
+
this.current = count - 1;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
this.current == count - 1;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
connectedCallback() {
|
|
215
|
+
const current = this.getAttribute('current');
|
|
216
|
+
if (current !== null) {
|
|
217
|
+
// first layout should always scroll instant
|
|
218
|
+
this.#scrollToIndex(Number(current), 'instant');
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
get [scrollContainerDom]() {
|
|
222
|
+
return this;
|
|
223
|
+
}
|
|
224
|
+
static {
|
|
225
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
return XSwiper = _classThis;
|
|
229
|
+
})();
|
|
230
|
+
export { XSwiper };
|
|
231
|
+
//# sourceMappingURL=XSwiper.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AttributeReactiveClass } from '@lynx-js/web-elements-reactive';
|
|
2
|
+
import { XSwiper } from './XSwiper.js';
|
|
3
|
+
export declare class XSwiperAutoScroll implements InstanceType<AttributeReactiveClass<typeof XSwiper>> {
|
|
4
|
+
#private;
|
|
5
|
+
static observedAttributes: string[];
|
|
6
|
+
constructor(dom: XSwiper);
|
|
7
|
+
dispose(): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { __esDecorate, __runInitializers, __setFunctionName } from "tslib";
|
|
2
|
+
/*
|
|
3
|
+
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
4
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
5
|
+
// LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import { registerAttributeHandler, } from '@lynx-js/web-elements-reactive';
|
|
8
|
+
let XSwiperAutoScroll = (() => {
|
|
9
|
+
let _instanceExtraInitializers = [];
|
|
10
|
+
let _private_handleCurrentChange_decorators;
|
|
11
|
+
let _private_handleCurrentChange_descriptor;
|
|
12
|
+
let _private_handleAutoplay_decorators;
|
|
13
|
+
let _private_handleAutoplay_descriptor;
|
|
14
|
+
return class XSwiperAutoScroll {
|
|
15
|
+
static {
|
|
16
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
17
|
+
_private_handleCurrentChange_decorators = [registerAttributeHandler('current', false)];
|
|
18
|
+
_private_handleAutoplay_decorators = [registerAttributeHandler('interval', false), registerAttributeHandler('autoplay', false)];
|
|
19
|
+
__esDecorate(this, _private_handleCurrentChange_descriptor = { value: __setFunctionName(function (newVal) {
|
|
20
|
+
const newval = Number(newVal);
|
|
21
|
+
if (!Number.isNaN(newval)) {
|
|
22
|
+
this.#dom.current = newval;
|
|
23
|
+
}
|
|
24
|
+
}, "#handleCurrentChange") }, _private_handleCurrentChange_decorators, { kind: "method", name: "#handleCurrentChange", static: false, private: true, access: { has: obj => #handleCurrentChange in obj, get: obj => obj.#handleCurrentChange }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
25
|
+
__esDecorate(this, _private_handleAutoplay_descriptor = { value: __setFunctionName(function () {
|
|
26
|
+
const enableAutoPlay = this.#dom.getAttribute('autoplay') !== null;
|
|
27
|
+
if (enableAutoPlay) {
|
|
28
|
+
const interval = this.#dom.getAttribute('interval');
|
|
29
|
+
let intervalValue = interval ? parseFloat(interval) : 5000;
|
|
30
|
+
if (Number.isNaN(intervalValue))
|
|
31
|
+
intervalValue = 5000;
|
|
32
|
+
this.#startAutoplay(intervalValue);
|
|
33
|
+
}
|
|
34
|
+
}, "#handleAutoplay") }, _private_handleAutoplay_decorators, { kind: "method", name: "#handleAutoplay", static: false, private: true, access: { has: obj => #handleAutoplay in obj, get: obj => obj.#handleAutoplay }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
35
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
36
|
+
}
|
|
37
|
+
static observedAttributes = ['current', 'interval', 'autoplay'];
|
|
38
|
+
#dom = __runInitializers(this, _instanceExtraInitializers);
|
|
39
|
+
constructor(dom) {
|
|
40
|
+
this.#dom = dom;
|
|
41
|
+
}
|
|
42
|
+
get #handleCurrentChange() { return _private_handleCurrentChange_descriptor.value; }
|
|
43
|
+
#autoPlayTimer;
|
|
44
|
+
#autoPlayTick = (() => {
|
|
45
|
+
this.#dom.scrollToNext();
|
|
46
|
+
}).bind(this);
|
|
47
|
+
#startAutoplay(interval) {
|
|
48
|
+
this.#stopAutoplay();
|
|
49
|
+
this.#autoPlayTimer = setInterval(this.#autoPlayTick, interval);
|
|
50
|
+
}
|
|
51
|
+
#stopAutoplay() {
|
|
52
|
+
if (this.#autoPlayTimer) {
|
|
53
|
+
clearInterval(this.#autoPlayTimer);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
get #handleAutoplay() { return _private_handleAutoplay_descriptor.value; }
|
|
57
|
+
dispose() {
|
|
58
|
+
this.#stopAutoplay();
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
})();
|
|
62
|
+
export { XSwiperAutoScroll };
|
|
63
|
+
//# sourceMappingURL=XSwiperAutoScroll.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AttributeReactiveClass } from '@lynx-js/web-elements-reactive';
|
|
2
|
+
import { XSwiper } from './XSwiper.js';
|
|
3
|
+
export declare class XSwiperCircular implements InstanceType<AttributeReactiveClass<typeof XSwiper>> {
|
|
4
|
+
#private;
|
|
5
|
+
static observedAttributes: string[];
|
|
6
|
+
constructor(dom: XSwiper);
|
|
7
|
+
dispose(): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { __esDecorate, __runInitializers, __setFunctionName } from "tslib";
|
|
2
|
+
/*
|
|
3
|
+
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
4
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
5
|
+
// LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import { bindSwitchToEventListener, genDomGetter, registerAttributeHandler, } from '@lynx-js/web-elements-reactive';
|
|
8
|
+
let XSwiperCircular = (() => {
|
|
9
|
+
let _instanceExtraInitializers = [];
|
|
10
|
+
let _private_handleCircular_decorators;
|
|
11
|
+
let _private_handleCircular_descriptor;
|
|
12
|
+
let _private_handleVerticalChange_decorators;
|
|
13
|
+
let _private_handleVerticalChange_descriptor;
|
|
14
|
+
return class XSwiperCircular {
|
|
15
|
+
static {
|
|
16
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
17
|
+
_private_handleCircular_decorators = [registerAttributeHandler('circular', false)];
|
|
18
|
+
_private_handleVerticalChange_decorators = [registerAttributeHandler('vertical', true)];
|
|
19
|
+
__esDecorate(this, _private_handleCircular_descriptor = { value: __setFunctionName(function (newVal) {
|
|
20
|
+
this.#listeners.forEach((l) => l(newVal));
|
|
21
|
+
if (newVal !== null) {
|
|
22
|
+
this.#dom.setAttribute('x-enable-change-event-for-indicator', '');
|
|
23
|
+
this.#changeEventHandler({
|
|
24
|
+
detail: {
|
|
25
|
+
current: this.#dom.current,
|
|
26
|
+
isDragged: false,
|
|
27
|
+
__isFirstLayout: true,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}, "#handleCircular") }, _private_handleCircular_decorators, { kind: "method", name: "#handleCircular", static: false, private: true, access: { has: obj => #handleCircular in obj, get: obj => obj.#handleCircular }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
32
|
+
__esDecorate(this, _private_handleVerticalChange_descriptor = { value: __setFunctionName(function (newVal) {
|
|
33
|
+
const enable = newVal !== null;
|
|
34
|
+
this.#isVertical = enable;
|
|
35
|
+
}, "#handleVerticalChange") }, _private_handleVerticalChange_decorators, { kind: "method", name: "#handleVerticalChange", static: false, private: true, access: { has: obj => #handleVerticalChange in obj, get: obj => obj.#handleVerticalChange }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
36
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
37
|
+
}
|
|
38
|
+
static observedAttributes = ['circular', 'vertical'];
|
|
39
|
+
#dom = __runInitializers(this, _instanceExtraInitializers);
|
|
40
|
+
#isVertical = false;
|
|
41
|
+
#pervTouchPosition;
|
|
42
|
+
#currentScrollDistance = 0;
|
|
43
|
+
#getContentContainer = genDomGetter(() => this.#dom.shadowRoot, '#content').bind(this);
|
|
44
|
+
constructor(dom) {
|
|
45
|
+
this.#dom = dom;
|
|
46
|
+
}
|
|
47
|
+
#getCircularFirstSlot = genDomGetter(() => this.#dom.shadowRoot, '#circular-start').bind(this);
|
|
48
|
+
#getCircularLastSlot = genDomGetter(() => this.#dom.shadowRoot, '#circular-end').bind(this);
|
|
49
|
+
#changeEventHandler(eventLikeObject) {
|
|
50
|
+
const numberOfChlidren = this.#dom.childElementCount;
|
|
51
|
+
if (numberOfChlidren > 2) {
|
|
52
|
+
const { current, isDragged, __isFirstLayout } = eventLikeObject.detail;
|
|
53
|
+
if (current === 0
|
|
54
|
+
|| current === numberOfChlidren - 1
|
|
55
|
+
|| current === 2
|
|
56
|
+
|| current === numberOfChlidren - 2) {
|
|
57
|
+
/**
|
|
58
|
+
* for current = 0
|
|
59
|
+
* start:[lastElement]
|
|
60
|
+
* main: [firstElement, ....]
|
|
61
|
+
* end: []
|
|
62
|
+
*
|
|
63
|
+
* for current = EOF
|
|
64
|
+
*
|
|
65
|
+
* start: []
|
|
66
|
+
* main: [..., lastElement],
|
|
67
|
+
* end: [firstElement]
|
|
68
|
+
*/
|
|
69
|
+
const contentContainer = this.#getContentContainer();
|
|
70
|
+
const elementsAtStart = this.#getCircularFirstSlot().assignedElements();
|
|
71
|
+
const elementsAtEnd = this.#getCircularLastSlot().assignedElements();
|
|
72
|
+
const firstElement = this.#dom.firstElementChild;
|
|
73
|
+
const lastElement = this.#dom.lastElementChild;
|
|
74
|
+
const snapDistance = this.#dom.snapDistance;
|
|
75
|
+
let targetElement;
|
|
76
|
+
if (current === 0) {
|
|
77
|
+
elementsAtEnd.forEach((e) => e.removeAttribute('slot'));
|
|
78
|
+
lastElement.setAttribute('slot', 'circular-start');
|
|
79
|
+
targetElement = firstElement;
|
|
80
|
+
}
|
|
81
|
+
else if (current === numberOfChlidren - 1) {
|
|
82
|
+
elementsAtStart.forEach((e) => e.removeAttribute('slot'));
|
|
83
|
+
firstElement.setAttribute('slot', 'circular-end');
|
|
84
|
+
targetElement = lastElement;
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
elementsAtStart.forEach((e) => e.removeAttribute('slot'));
|
|
88
|
+
elementsAtEnd.forEach((e) => e.removeAttribute('slot'));
|
|
89
|
+
targetElement = this.#dom.children[current];
|
|
90
|
+
}
|
|
91
|
+
// make sure the center offset of first element does not change.
|
|
92
|
+
// make scrollleft + midWidth/2 = offsetLeft/2 + itemWidth - snapDistance
|
|
93
|
+
if (this.#isVertical) {
|
|
94
|
+
const midHeight = this.#dom.getAttribute('mode') === 'carousel'
|
|
95
|
+
? (contentContainer.clientHeight * 0.8) / 2
|
|
96
|
+
: contentContainer.clientHeight / 2;
|
|
97
|
+
this.#currentScrollDistance = targetElement.offsetTop
|
|
98
|
+
+ targetElement.offsetHeight / 2
|
|
99
|
+
- snapDistance
|
|
100
|
+
- midHeight;
|
|
101
|
+
contentContainer.scrollTop = this.#currentScrollDistance;
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
const midWidth = this.#dom.getAttribute('mode') === 'carousel'
|
|
105
|
+
? (contentContainer.clientWidth * 0.8) / 2
|
|
106
|
+
: contentContainer.clientWidth / 2;
|
|
107
|
+
this.#currentScrollDistance = targetElement.offsetLeft
|
|
108
|
+
+ targetElement.offsetWidth / 2
|
|
109
|
+
- snapDistance
|
|
110
|
+
- midWidth;
|
|
111
|
+
contentContainer.scrollLeft = this.#currentScrollDistance;
|
|
112
|
+
}
|
|
113
|
+
if (!isDragged) {
|
|
114
|
+
const mode = this.#dom.getAttribute('mode');
|
|
115
|
+
// first layout, the following mode position is the leftmost, no scrollToSnapPosition is needed
|
|
116
|
+
if (__isFirstLayout
|
|
117
|
+
&& (mode === null || mode === 'normal' || mode === 'carousel'
|
|
118
|
+
|| mode === 'carry')) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
// first layout should always scroll instant
|
|
122
|
+
this.#scrollToSnapPosition(__isFirstLayout ? 'instant' : 'smooth');
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
#scrollToSnapPosition(behavior) {
|
|
128
|
+
const contentContainer = this.#getContentContainer();
|
|
129
|
+
const snapDistance = this.#dom.snapDistance;
|
|
130
|
+
contentContainer.scrollBy({
|
|
131
|
+
top: this.#isVertical ? snapDistance : 0,
|
|
132
|
+
left: this.#isVertical ? 0 : snapDistance,
|
|
133
|
+
behavior: behavior ?? 'smooth',
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
#listeners = [
|
|
137
|
+
bindSwitchToEventListener(() => this.#dom, 'change', this.#changeEventHandler.bind(this), { passive: true }),
|
|
138
|
+
bindSwitchToEventListener(() => this.#dom, 'touchmove', this.#handleTouchEvent.bind(this), { passive: false }),
|
|
139
|
+
bindSwitchToEventListener(() => this.#dom, 'touchend', this.#handleEndEvent.bind(this), { passive: false }),
|
|
140
|
+
bindSwitchToEventListener(() => this.#dom, 'touchcancel', this.#handleEndEvent.bind(this), { passive: false }),
|
|
141
|
+
];
|
|
142
|
+
get #handleCircular() { return _private_handleCircular_descriptor.value; }
|
|
143
|
+
#handleTouchEvent(event) {
|
|
144
|
+
const touch = event.touches.item(0);
|
|
145
|
+
if (touch) {
|
|
146
|
+
const currentTouchPosition = this.#isVertical ? touch.pageY : touch.pageX;
|
|
147
|
+
if (this.#pervTouchPosition !== undefined) {
|
|
148
|
+
this.#startScrolling();
|
|
149
|
+
const scrollMoveDistance = this.#pervTouchPosition
|
|
150
|
+
- currentTouchPosition;
|
|
151
|
+
this.#currentScrollDistance += scrollMoveDistance;
|
|
152
|
+
}
|
|
153
|
+
this.#pervTouchPosition = currentTouchPosition;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
#handleEndEvent(_event) {
|
|
157
|
+
this.#stopScrolling();
|
|
158
|
+
this.#scrollToSnapPosition();
|
|
159
|
+
this.#pervTouchPosition = undefined;
|
|
160
|
+
}
|
|
161
|
+
get #handleVerticalChange() { return _private_handleVerticalChange_descriptor.value; }
|
|
162
|
+
#scrollTimer;
|
|
163
|
+
#startScrolling() {
|
|
164
|
+
if (!this.#scrollTimer) {
|
|
165
|
+
const contentContainer = this.#getContentContainer();
|
|
166
|
+
this.#currentScrollDistance = this.#isVertical
|
|
167
|
+
? contentContainer.scrollTop
|
|
168
|
+
: contentContainer.scrollLeft;
|
|
169
|
+
this.#scrollTimer = setInterval(() => {
|
|
170
|
+
if (this.#isVertical) {
|
|
171
|
+
contentContainer.scrollTop = this.#currentScrollDistance;
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
contentContainer.scrollLeft = this.#currentScrollDistance;
|
|
175
|
+
}
|
|
176
|
+
}, 10);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
#stopScrolling() {
|
|
180
|
+
if (this.#scrollTimer) {
|
|
181
|
+
clearInterval(this.#scrollTimer);
|
|
182
|
+
this.#scrollTimer = undefined;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
dispose() {
|
|
186
|
+
this.#stopScrolling();
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
})();
|
|
190
|
+
export { XSwiperCircular };
|
|
191
|
+
//# sourceMappingURL=XSwiperCircular.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type AttributeReactiveClass } from '@lynx-js/web-elements-reactive';
|
|
2
|
+
import { XSwiper } from './XSwiper.js';
|
|
3
|
+
export declare class XSwipeEvents implements InstanceType<AttributeReactiveClass<typeof XSwiper>> {
|
|
4
|
+
#private;
|
|
5
|
+
static observedAttributes: string[];
|
|
6
|
+
constructor(dom: XSwiper);
|
|
7
|
+
connectedCallback(): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { __esDecorate, __runInitializers, __setFunctionName } from "tslib";
|
|
2
|
+
/*
|
|
3
|
+
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
4
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
5
|
+
// LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import { bindSwitchToEventListener, genDomGetter, registerAttributeHandler, } from '@lynx-js/web-elements-reactive';
|
|
8
|
+
import { commonComponentEventSetting } from '../common/commonEventInitConfiguration.js';
|
|
9
|
+
import { useScrollEnd } from '../common/constants.js';
|
|
10
|
+
let XSwipeEvents = (() => {
|
|
11
|
+
let _instanceExtraInitializers = [];
|
|
12
|
+
let _private_handleEnableTransitionEvent_decorators;
|
|
13
|
+
let _private_handleEnableTransitionEvent_initializers = [];
|
|
14
|
+
let _private_handleEnableTransitionEvent_extraInitializers = [];
|
|
15
|
+
let _private_enableScrollEventProcessor_decorators;
|
|
16
|
+
let _private_enableScrollEventProcessor_descriptor;
|
|
17
|
+
return class XSwipeEvents {
|
|
18
|
+
static {
|
|
19
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
20
|
+
_private_handleEnableTransitionEvent_decorators = [registerAttributeHandler('x-enable-transition-event', true)];
|
|
21
|
+
_private_enableScrollEventProcessor_decorators = [registerAttributeHandler('x-enable-scrollstart-event', false), registerAttributeHandler('x-enable-scrollend-event', false), registerAttributeHandler('x-enable-change-event', false), registerAttributeHandler('x-enable-change-event-for-indicator', false)];
|
|
22
|
+
__esDecorate(this, _private_enableScrollEventProcessor_descriptor = { value: __setFunctionName(function () {
|
|
23
|
+
const enableScrollstartEvent = this.#dom.getAttribute('x-enable-scrollstart-event') !== null;
|
|
24
|
+
const enableScrollendEvent = this.#dom.getAttribute('x-enable-scrollend-event') !== null;
|
|
25
|
+
const enableChangeEvent = this.#dom.getAttribute('x-enable-change-event') !== null;
|
|
26
|
+
const enableChangeforindicatorEvent = this.#dom.getAttribute('x-enable-change-event-for-indicator') !== null;
|
|
27
|
+
const enableEvent = enableChangeEvent
|
|
28
|
+
|| enableScrollendEvent
|
|
29
|
+
|| enableScrollstartEvent
|
|
30
|
+
|| enableChangeforindicatorEvent;
|
|
31
|
+
this.#listeners.forEach((l) => l(enableEvent ? '' : null));
|
|
32
|
+
}, "#enableScrollEventProcessor") }, _private_enableScrollEventProcessor_decorators, { kind: "method", name: "#enableScrollEventProcessor", static: false, private: true, access: { has: obj => #enableScrollEventProcessor in obj, get: obj => obj.#enableScrollEventProcessor }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
33
|
+
__esDecorate(null, null, _private_handleEnableTransitionEvent_decorators, { kind: "field", name: "#handleEnableTransitionEvent", static: false, private: true, access: { has: obj => #handleEnableTransitionEvent in obj, get: obj => obj.#handleEnableTransitionEvent, set: (obj, value) => { obj.#handleEnableTransitionEvent = value; } }, metadata: _metadata }, _private_handleEnableTransitionEvent_initializers, _private_handleEnableTransitionEvent_extraInitializers);
|
|
34
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
35
|
+
}
|
|
36
|
+
static observedAttributes = [
|
|
37
|
+
'x-enable-scrollstart-event',
|
|
38
|
+
'x-enable-scrollend-event',
|
|
39
|
+
'x-enable-change-event',
|
|
40
|
+
'x-enable-change-event-for-indicator',
|
|
41
|
+
'x-enable-transition-event',
|
|
42
|
+
];
|
|
43
|
+
#dom = __runInitializers(this, _instanceExtraInitializers);
|
|
44
|
+
#current = 0;
|
|
45
|
+
#pervScrollPosition = 0;
|
|
46
|
+
#dragging = false;
|
|
47
|
+
#debounceScrollForMockingScrollEnd;
|
|
48
|
+
#scrollStarted = false;
|
|
49
|
+
constructor(dom) {
|
|
50
|
+
this.#dom = dom;
|
|
51
|
+
}
|
|
52
|
+
#getContentContainer = genDomGetter(() => this.#dom.shadowRoot, '#content').bind(this);
|
|
53
|
+
#handleEnableTransitionEvent = __runInitializers(this, _private_handleEnableTransitionEvent_initializers, bindSwitchToEventListener(this.#getContentContainer, 'scroll', this.#scrollEventListenerForTransition, { passive: true }));
|
|
54
|
+
#handleScroll() {
|
|
55
|
+
if (!useScrollEnd) {
|
|
56
|
+
// debounce
|
|
57
|
+
clearTimeout(this.#debounceScrollForMockingScrollEnd);
|
|
58
|
+
this.#debounceScrollForMockingScrollEnd = setTimeout(() => {
|
|
59
|
+
this.#handleScrollEnd();
|
|
60
|
+
}, 100);
|
|
61
|
+
}
|
|
62
|
+
if (!this.#scrollStarted) {
|
|
63
|
+
this.#dom.dispatchEvent(new CustomEvent('scrollstart', {
|
|
64
|
+
...commonComponentEventSetting,
|
|
65
|
+
detail: {
|
|
66
|
+
current: this.#current,
|
|
67
|
+
isDragged: this.#dragging,
|
|
68
|
+
},
|
|
69
|
+
}));
|
|
70
|
+
this.#scrollStarted = true;
|
|
71
|
+
}
|
|
72
|
+
const contentContainer = this.#getContentContainer();
|
|
73
|
+
const isVertical = this.#dom.isVertical;
|
|
74
|
+
/* already scrolled distance */
|
|
75
|
+
const currentScrollDistance = isVertical
|
|
76
|
+
? contentContainer.scrollTop
|
|
77
|
+
: contentContainer.scrollLeft;
|
|
78
|
+
const pageLength = isVertical
|
|
79
|
+
? contentContainer.clientHeight
|
|
80
|
+
: contentContainer.clientWidth;
|
|
81
|
+
const totalScrollDistance = isVertical
|
|
82
|
+
? contentContainer.scrollHeight
|
|
83
|
+
: contentContainer.scrollWidth;
|
|
84
|
+
if (Math.abs(this.#pervScrollPosition - currentScrollDistance)
|
|
85
|
+
> pageLength / 4
|
|
86
|
+
|| currentScrollDistance < 10
|
|
87
|
+
|| Math.abs(currentScrollDistance - totalScrollDistance) <= pageLength) {
|
|
88
|
+
const current = this.#dom.current;
|
|
89
|
+
if (current !== this.#current) {
|
|
90
|
+
this.#dom.dispatchEvent(new CustomEvent('change', {
|
|
91
|
+
...commonComponentEventSetting,
|
|
92
|
+
detail: {
|
|
93
|
+
current,
|
|
94
|
+
isDragged: this.#dragging,
|
|
95
|
+
},
|
|
96
|
+
}));
|
|
97
|
+
this.#current = current;
|
|
98
|
+
}
|
|
99
|
+
this.#pervScrollPosition = currentScrollDistance;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
#handleScrollEnd() {
|
|
103
|
+
this.#dom.dispatchEvent(new CustomEvent('lynxscrollend', {
|
|
104
|
+
...commonComponentEventSetting,
|
|
105
|
+
detail: {
|
|
106
|
+
current: this.#current,
|
|
107
|
+
},
|
|
108
|
+
}));
|
|
109
|
+
this.#scrollStarted = false;
|
|
110
|
+
}
|
|
111
|
+
#handleTouchStart() {
|
|
112
|
+
this.#dragging = true;
|
|
113
|
+
}
|
|
114
|
+
#handleTouchEndAndCancel() {
|
|
115
|
+
this.#dragging = false;
|
|
116
|
+
}
|
|
117
|
+
#scrollEventListenerForTransition() {
|
|
118
|
+
this.#dom.dispatchEvent(new CustomEvent('transition', {
|
|
119
|
+
...commonComponentEventSetting,
|
|
120
|
+
detail: {
|
|
121
|
+
dx: this.#getContentContainer().scrollLeft,
|
|
122
|
+
dy: this.#getContentContainer().scrollTop,
|
|
123
|
+
},
|
|
124
|
+
}));
|
|
125
|
+
}
|
|
126
|
+
#listeners = (__runInitializers(this, _private_handleEnableTransitionEvent_extraInitializers), [
|
|
127
|
+
bindSwitchToEventListener(this.#getContentContainer, 'scroll', this.#handleScroll.bind(this), { passive: true }),
|
|
128
|
+
bindSwitchToEventListener(this.#getContentContainer, 'touchstart', this.#handleTouchStart.bind(this), { passive: true }),
|
|
129
|
+
bindSwitchToEventListener(this.#getContentContainer, 'touchend', this.#handleTouchEndAndCancel.bind(this), { passive: true }),
|
|
130
|
+
bindSwitchToEventListener(this.#getContentContainer, 'touchcancel', this.#handleTouchEndAndCancel.bind(this), { passive: true }),
|
|
131
|
+
bindSwitchToEventListener(this.#getContentContainer, 'scrollend', this.#handleScrollEnd.bind(this), { passive: true }),
|
|
132
|
+
]);
|
|
133
|
+
get #enableScrollEventProcessor() { return _private_enableScrollEventProcessor_descriptor.value; }
|
|
134
|
+
connectedCallback() {
|
|
135
|
+
this.#current = parseFloat(this.#dom.getAttribute('current') ?? '0');
|
|
136
|
+
const isVertical = this.#dom.isVertical;
|
|
137
|
+
this.#pervScrollPosition = isVertical
|
|
138
|
+
? this.#getContentContainer().scrollTop
|
|
139
|
+
: this.#getContentContainer().scrollLeft;
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
})();
|
|
143
|
+
export { XSwipeEvents };
|
|
144
|
+
//# sourceMappingURL=XSwiperEvents.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AttributeReactiveClass } from '@lynx-js/web-elements-reactive';
|
|
2
|
+
import { XSwiper } from './XSwiper.js';
|
|
3
|
+
export declare class XSwiperIndicator implements InstanceType<AttributeReactiveClass<typeof XSwiper>> {
|
|
4
|
+
#private;
|
|
5
|
+
static observedAttributes: string[];
|
|
6
|
+
constructor(dom: XSwiper);
|
|
7
|
+
connectedCallback(): void;
|
|
8
|
+
dispose(): void;
|
|
9
|
+
}
|