@everymatrix/general-slider 1.43.4 → 1.45.0
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/cjs/app-globals-3a1e7e63.js +5 -0
- package/dist/cjs/general-slider.cjs.entry.js +195 -221
- package/dist/cjs/general-slider.cjs.js +16 -10
- package/dist/cjs/index-a188f427.js +1190 -0
- package/dist/cjs/loader.cjs.js +6 -12
- package/dist/collection/collection-manifest.json +3 -3
- package/dist/collection/components/general-slider/general-slider.js +365 -391
- package/dist/collection/components/general-slider/index.js +1 -0
- package/dist/collection/utils/utils.js +1 -1
- package/dist/esm/app-globals-0f993ce5.js +3 -0
- package/dist/esm/general-slider.entry.js +195 -221
- package/dist/esm/general-slider.js +13 -10
- package/dist/esm/index-81e4031d.js +1163 -0
- package/dist/esm/loader.js +6 -12
- package/dist/general-slider/general-slider.esm.js +1 -1
- package/dist/general-slider/p-0c9064c9.entry.js +1 -0
- package/dist/general-slider/p-b2733fb4.js +2 -0
- package/dist/general-slider/p-e1255160.js +1 -0
- package/dist/stencil.config.dev.js +17 -0
- package/dist/stencil.config.js +14 -19
- package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/general-slider/.stencil/packages/stencil/general-slider/stencil.config.d.ts +2 -0
- package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/general-slider/.stencil/packages/stencil/general-slider/stencil.config.dev.d.ts +2 -0
- package/dist/types/components/general-slider/general-slider.d.ts +67 -67
- package/dist/types/components/general-slider/index.d.ts +1 -0
- package/dist/types/stencil-public-runtime.d.ts +142 -33
- package/loader/cdn.js +1 -3
- package/loader/index.cjs.js +1 -3
- package/loader/index.d.ts +13 -1
- package/loader/index.es2017.js +1 -3
- package/loader/index.js +1 -3
- package/loader/package.json +1 -0
- package/package.json +8 -4
- package/dist/cjs/index-813e9dd4.js +0 -1176
- package/dist/components/general-slider.d.ts +0 -11
- package/dist/components/general-slider.js +0 -260
- package/dist/components/index.d.ts +0 -26
- package/dist/components/index.js +0 -1
- package/dist/esm/index-3bef6f6d.js +0 -1150
- package/dist/esm/polyfills/core-js.js +0 -11
- package/dist/esm/polyfills/css-shim.js +0 -1
- package/dist/esm/polyfills/dom.js +0 -79
- package/dist/esm/polyfills/es5-html-element.js +0 -1
- package/dist/esm/polyfills/index.js +0 -34
- package/dist/esm/polyfills/system.js +0 -6
- package/dist/general-slider/p-1d97b302.js +0 -1
- package/dist/general-slider/p-20e28994.entry.js +0 -1
- package/dist/types/Users/adrian.pripon/Documents/Work/widgets-stencil/packages/general-slider/.stencil/packages/general-slider/stencil.config.d.ts +0 -2
|
@@ -1,406 +1,380 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { h } from "@stencil/core";
|
|
2
2
|
export class GeneralSlider {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
* Auto Slide loop time
|
|
26
|
-
*/
|
|
27
|
-
this.loopTime = 1;
|
|
28
|
-
/**
|
|
29
|
-
* Auto fill the Item height
|
|
30
|
-
*/
|
|
31
|
-
this.autoItemHeight = false;
|
|
32
|
-
/**
|
|
33
|
-
* Client custom styling via inline styles
|
|
34
|
-
*/
|
|
35
|
-
this.clientStyling = '';
|
|
36
|
-
/**
|
|
37
|
-
* Client custom styling via url
|
|
38
|
-
*/
|
|
39
|
-
this.clientStylingUrl = '';
|
|
40
|
-
this.currentSlideNumber = 0;
|
|
41
|
-
this.slidesCount = 0;
|
|
42
|
-
this.limitStylingAppends = false;
|
|
43
|
-
this.slides = null;
|
|
44
|
-
this.slideWidth = 0;
|
|
45
|
-
this.currentPage = 0;
|
|
46
|
-
this.controls = {
|
|
47
|
-
Prev: null,
|
|
48
|
-
Next: null
|
|
49
|
-
};
|
|
50
|
-
this.xDown = null;
|
|
51
|
-
this.yDown = null;
|
|
52
|
-
}
|
|
53
|
-
slide(next) {
|
|
54
|
-
let slideTo = 0;
|
|
55
|
-
if (next) {
|
|
56
|
-
slideTo = this.currentSlideNumber + this.slideNumber;
|
|
3
|
+
constructor() {
|
|
4
|
+
this.slides = null;
|
|
5
|
+
this.slideWidth = 0;
|
|
6
|
+
this.currentPage = 0;
|
|
7
|
+
this.controls = {
|
|
8
|
+
Prev: null,
|
|
9
|
+
Next: null
|
|
10
|
+
};
|
|
11
|
+
this.xDown = null;
|
|
12
|
+
this.yDown = null;
|
|
13
|
+
this.slideNumber = 3;
|
|
14
|
+
this.slideShow = 3;
|
|
15
|
+
this.showArrow = true;
|
|
16
|
+
this.showButton = false;
|
|
17
|
+
this.autoSlide = false;
|
|
18
|
+
this.loopTime = 1;
|
|
19
|
+
this.autoItemHeight = false;
|
|
20
|
+
this.clientStyling = '';
|
|
21
|
+
this.clientStylingUrl = '';
|
|
22
|
+
this.currentSlideNumber = 0;
|
|
23
|
+
this.slidesCount = 0;
|
|
24
|
+
this.limitStylingAppends = false;
|
|
57
25
|
}
|
|
58
|
-
|
|
59
|
-
|
|
26
|
+
slide(next) {
|
|
27
|
+
let slideTo = 0;
|
|
28
|
+
if (next) {
|
|
29
|
+
slideTo = this.currentSlideNumber + this.slideNumber;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
slideTo = this.currentSlideNumber - this.slideNumber;
|
|
33
|
+
}
|
|
34
|
+
if (slideTo < 0 || slideTo >= this.slidesCount)
|
|
35
|
+
return;
|
|
36
|
+
this.currentSlideNumber = slideTo;
|
|
37
|
+
this.currentPage = this.currentSlideNumber / this.slideNumber;
|
|
38
|
+
this.updateListStyle();
|
|
60
39
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
this.updateListStyle();
|
|
66
|
-
}
|
|
67
|
-
slideTo(page) {
|
|
68
|
-
this.currentSlideNumber = page * this.slideNumber;
|
|
69
|
-
this.currentPage = page;
|
|
70
|
-
this.updateListStyle();
|
|
71
|
-
}
|
|
72
|
-
updateControls() {
|
|
73
|
-
this.switchControl('Prev', (this.currentSlideNumber === 0) ? false : true);
|
|
74
|
-
this.switchControl('Next', (this.currentSlideNumber === this.slidesCount - this.slideShow) ? false : true);
|
|
75
|
-
}
|
|
76
|
-
switchControl(type, enabled) {
|
|
77
|
-
if (this.controls[type]) {
|
|
78
|
-
this.controls[type].disabled = !enabled;
|
|
40
|
+
slideTo(page) {
|
|
41
|
+
this.currentSlideNumber = page * this.slideNumber;
|
|
42
|
+
this.currentPage = page;
|
|
43
|
+
this.updateListStyle();
|
|
79
44
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
this.slideNumber = 1;
|
|
84
|
-
if (!this.slideShow)
|
|
85
|
-
this.slideShow = 1;
|
|
86
|
-
}
|
|
87
|
-
componentDidLoad() {
|
|
88
|
-
this.slides = this.slotEl.assignedElements();
|
|
89
|
-
this.slidesCount = this.slides.length;
|
|
90
|
-
for (let type in this.controls) {
|
|
91
|
-
this.controls[type] = this.el.shadowRoot.querySelector('.Button' + type);
|
|
45
|
+
updateControls() {
|
|
46
|
+
this.switchControl('Prev', (this.currentSlideNumber === 0) ? false : true);
|
|
47
|
+
this.switchControl('Next', (this.currentSlideNumber === this.slidesCount - this.slideShow) ? false : true);
|
|
92
48
|
}
|
|
93
|
-
|
|
94
|
-
|
|
49
|
+
switchControl(type, enabled) {
|
|
50
|
+
if (this.controls[type]) {
|
|
51
|
+
this.controls[type].disabled = !enabled;
|
|
52
|
+
}
|
|
95
53
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
this.limitStylingAppends = true;
|
|
54
|
+
componentWillLoad() {
|
|
55
|
+
if (!this.slideNumber)
|
|
56
|
+
this.slideNumber = 1;
|
|
57
|
+
if (!this.slideShow)
|
|
58
|
+
this.slideShow = 1;
|
|
102
59
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
this.
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
60
|
+
componentDidLoad() {
|
|
61
|
+
this.slides = this.slotEl.assignedElements();
|
|
62
|
+
this.slidesCount = this.slides.length;
|
|
63
|
+
for (let type in this.controls) {
|
|
64
|
+
this.controls[type] = this.el.shadowRoot.querySelector('.Button' + type);
|
|
65
|
+
}
|
|
66
|
+
if (this.autoSlide) {
|
|
67
|
+
this.setSlideAutoInterval();
|
|
68
|
+
}
|
|
69
|
+
if (!this.limitStylingAppends && this.el.shadowRoot) {
|
|
70
|
+
if (this.clientStyling)
|
|
71
|
+
this.setClientStyling();
|
|
72
|
+
if (this.clientStylingUrl)
|
|
73
|
+
this.setClientStylingURL();
|
|
74
|
+
this.limitStylingAppends = true;
|
|
75
|
+
}
|
|
116
76
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
disconnectedCallback() {
|
|
133
|
-
this.el.removeEventListener('touchstart', this.handleTouchStart);
|
|
134
|
-
this.el.removeEventListener('touchmove', this.handleTouchMove);
|
|
135
|
-
}
|
|
136
|
-
handleTouchStart(evt) {
|
|
137
|
-
const firstTouch = this.getTouches(evt)[0];
|
|
138
|
-
this.xDown = firstTouch.clientX;
|
|
139
|
-
this.yDown = firstTouch.clientY;
|
|
140
|
-
clearInterval(this.sliderInterval);
|
|
141
|
-
}
|
|
142
|
-
getTouches(evt) {
|
|
143
|
-
return evt.touches || evt.originalEvent.touches;
|
|
144
|
-
}
|
|
145
|
-
handleTouchMove(evt) {
|
|
146
|
-
if (!this.xDown || !this.yDown)
|
|
147
|
-
return;
|
|
148
|
-
let xUp = evt.touches[0].clientX;
|
|
149
|
-
let yUp = evt.touches[0].clientY;
|
|
150
|
-
let xDiff = this.xDown - xUp;
|
|
151
|
-
let yDiff = this.yDown - yUp;
|
|
152
|
-
if (Math.abs(xDiff) > Math.abs(yDiff)) {
|
|
153
|
-
if (xDiff > 0) {
|
|
154
|
-
this.slide(true);
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
this.slide(false);
|
|
158
|
-
}
|
|
77
|
+
componentDidRender() {
|
|
78
|
+
if (this.slides)
|
|
79
|
+
this.slideWidth = this.slides[0].offsetWidth;
|
|
80
|
+
this.el.addEventListener('touchstart', this.handleTouchStart.bind(this), { passive: true });
|
|
81
|
+
this.el.addEventListener('touchmove', this.handleTouchMove.bind(this), { passive: true });
|
|
82
|
+
this.updateListStyle();
|
|
83
|
+
if (!this.limitStylingAppends && this.el.shadowRoot) {
|
|
84
|
+
if (this.clientStyling)
|
|
85
|
+
this.setClientStyling();
|
|
86
|
+
if (this.clientStylingUrl)
|
|
87
|
+
this.setClientStylingURL();
|
|
88
|
+
this.limitStylingAppends = true;
|
|
89
|
+
}
|
|
159
90
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
91
|
+
updateListStyle() {
|
|
92
|
+
if (!this.autoItemHeight)
|
|
93
|
+
return;
|
|
94
|
+
if (this.slides === null)
|
|
95
|
+
return;
|
|
96
|
+
this.slides.forEach((li, index) => {
|
|
97
|
+
if (index >= this.currentPage * this.slideNumber && index < (this.currentPage + 1) * this.slideNumber) {
|
|
98
|
+
li.classList.remove('hide');
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
li.classList.add('hide');
|
|
102
|
+
}
|
|
103
|
+
});
|
|
164
104
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
if (this.loopTime == 0) {
|
|
169
|
-
return;
|
|
105
|
+
disconnectedCallback() {
|
|
106
|
+
this.el.removeEventListener('touchstart', this.handleTouchStart);
|
|
107
|
+
this.el.removeEventListener('touchmove', this.handleTouchMove);
|
|
170
108
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
this.
|
|
175
|
-
}
|
|
176
|
-
else {
|
|
177
|
-
this.slideTo(0);
|
|
178
|
-
}
|
|
179
|
-
}, Number(this.loopTime) * 1000);
|
|
180
|
-
}
|
|
181
|
-
componentDidUpdate() {
|
|
182
|
-
this.sliderEl.style.transform = `translateX(${this.currentSlideNumber * this.slideWidth * -1}px)`;
|
|
183
|
-
this.updateControls();
|
|
184
|
-
}
|
|
185
|
-
switchLoopStatus(isMouseMoveEnter) {
|
|
186
|
-
if (!this.autoSlide)
|
|
187
|
-
return;
|
|
188
|
-
if (this.loopTime > 0) {
|
|
189
|
-
if (isMouseMoveEnter) {
|
|
109
|
+
handleTouchStart(evt) {
|
|
110
|
+
const firstTouch = this.getTouches(evt)[0];
|
|
111
|
+
this.xDown = firstTouch.clientX;
|
|
112
|
+
this.yDown = firstTouch.clientY;
|
|
190
113
|
clearInterval(this.sliderInterval);
|
|
191
|
-
}
|
|
192
|
-
else {
|
|
193
|
-
this.setSlideAutoInterval();
|
|
194
|
-
}
|
|
195
114
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
const sheet = new CSSStyleSheet();
|
|
199
|
-
// @ts-ignore
|
|
200
|
-
sheet.replace(this.clientStyling);
|
|
201
|
-
// @ts-ignore
|
|
202
|
-
this.el.shadowRoot.adoptedStyleSheets = [...this.el.shadowRoot.adoptedStyleSheets, sheet];
|
|
203
|
-
}
|
|
204
|
-
setClientStylingURL() {
|
|
205
|
-
let url = new URL(this.clientStylingUrl);
|
|
206
|
-
fetch(url.href)
|
|
207
|
-
.then((res) => res.text())
|
|
208
|
-
.then((data) => {
|
|
209
|
-
const sheet = new CSSStyleSheet();
|
|
210
|
-
// @ts-ignore
|
|
211
|
-
sheet.replace(data);
|
|
212
|
-
// @ts-ignore
|
|
213
|
-
this.el.shadowRoot.adoptedStyleSheets = [...this.el.shadowRoot.adoptedStyleSheets, sheet];
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
render() {
|
|
217
|
-
return (h("div", { class: "GeneralSlider" },
|
|
218
|
-
h("div", { class: "Slider" },
|
|
219
|
-
this.showArrow &&
|
|
220
|
-
h("div", null,
|
|
221
|
-
h("button", { type: "button", class: "Button ButtonNext", onClick: this.slide.bind(this, true), onMouseEnter: this.switchLoopStatus.bind(this, true), onMouseLeave: this.switchLoopStatus.bind(this, false) }, ">"),
|
|
222
|
-
h("button", { type: "button", class: "Button ButtonPrev", onClick: this.slide.bind(this, false), onMouseEnter: this.switchLoopStatus.bind(this, true), onMouseLeave: this.switchLoopStatus.bind(this, false) }, "<")),
|
|
223
|
-
h("ul", { class: `SliderList Col-${this.slideShow}`, part: "SliderList", onMouseEnter: this.switchLoopStatus.bind(this, true), onMouseLeave: this.switchLoopStatus.bind(this, false), ref: (el) => this.sliderEl = el },
|
|
224
|
-
h("slot", { ref: (el) => this.slotEl = el }))),
|
|
225
|
-
this.showButton && this.slidesCount > 0 &&
|
|
226
|
-
h("div", { class: "PageButtons", part: "PageButtons" }, [...Array(this.slidesCount / this.slideNumber)].map((_x, i) => h("div", { class: `PageButton ${this.currentPage == i ? 'active' : ''}`, title: `page${i}`, onClick: this.slideTo.bind(this, i), onMouseEnter: this.switchLoopStatus.bind(this, true), onMouseLeave: this.switchLoopStatus.bind(this, false) }, "\u00A0")))));
|
|
227
|
-
}
|
|
228
|
-
static get is() { return "general-slider"; }
|
|
229
|
-
static get encapsulation() { return "shadow"; }
|
|
230
|
-
static get originalStyleUrls() { return {
|
|
231
|
-
"$": ["general-slider.scss"]
|
|
232
|
-
}; }
|
|
233
|
-
static get styleUrls() { return {
|
|
234
|
-
"$": ["general-slider.css"]
|
|
235
|
-
}; }
|
|
236
|
-
static get properties() { return {
|
|
237
|
-
"slideNumber": {
|
|
238
|
-
"type": "number",
|
|
239
|
-
"mutable": false,
|
|
240
|
-
"complexType": {
|
|
241
|
-
"original": "number",
|
|
242
|
-
"resolved": "number",
|
|
243
|
-
"references": {}
|
|
244
|
-
},
|
|
245
|
-
"required": false,
|
|
246
|
-
"optional": false,
|
|
247
|
-
"docs": {
|
|
248
|
-
"tags": [],
|
|
249
|
-
"text": "Slide Count"
|
|
250
|
-
},
|
|
251
|
-
"attribute": "slide-number",
|
|
252
|
-
"reflect": false,
|
|
253
|
-
"defaultValue": "3"
|
|
254
|
-
},
|
|
255
|
-
"slideShow": {
|
|
256
|
-
"type": "number",
|
|
257
|
-
"mutable": false,
|
|
258
|
-
"complexType": {
|
|
259
|
-
"original": "number",
|
|
260
|
-
"resolved": "number",
|
|
261
|
-
"references": {}
|
|
262
|
-
},
|
|
263
|
-
"required": false,
|
|
264
|
-
"optional": false,
|
|
265
|
-
"docs": {
|
|
266
|
-
"tags": [],
|
|
267
|
-
"text": "Slides to show"
|
|
268
|
-
},
|
|
269
|
-
"attribute": "slide-show",
|
|
270
|
-
"reflect": false,
|
|
271
|
-
"defaultValue": "3"
|
|
272
|
-
},
|
|
273
|
-
"showArrow": {
|
|
274
|
-
"type": "boolean",
|
|
275
|
-
"mutable": false,
|
|
276
|
-
"complexType": {
|
|
277
|
-
"original": "boolean",
|
|
278
|
-
"resolved": "boolean",
|
|
279
|
-
"references": {}
|
|
280
|
-
},
|
|
281
|
-
"required": false,
|
|
282
|
-
"optional": false,
|
|
283
|
-
"docs": {
|
|
284
|
-
"tags": [],
|
|
285
|
-
"text": "Display the arrow icon"
|
|
286
|
-
},
|
|
287
|
-
"attribute": "show-arrow",
|
|
288
|
-
"reflect": false,
|
|
289
|
-
"defaultValue": "true"
|
|
290
|
-
},
|
|
291
|
-
"showButton": {
|
|
292
|
-
"type": "boolean",
|
|
293
|
-
"mutable": false,
|
|
294
|
-
"complexType": {
|
|
295
|
-
"original": "boolean",
|
|
296
|
-
"resolved": "boolean",
|
|
297
|
-
"references": {}
|
|
298
|
-
},
|
|
299
|
-
"required": false,
|
|
300
|
-
"optional": false,
|
|
301
|
-
"docs": {
|
|
302
|
-
"tags": [],
|
|
303
|
-
"text": "Display the button"
|
|
304
|
-
},
|
|
305
|
-
"attribute": "show-button",
|
|
306
|
-
"reflect": false,
|
|
307
|
-
"defaultValue": "false"
|
|
308
|
-
},
|
|
309
|
-
"autoSlide": {
|
|
310
|
-
"type": "boolean",
|
|
311
|
-
"mutable": false,
|
|
312
|
-
"complexType": {
|
|
313
|
-
"original": "boolean",
|
|
314
|
-
"resolved": "boolean",
|
|
315
|
-
"references": {}
|
|
316
|
-
},
|
|
317
|
-
"required": false,
|
|
318
|
-
"optional": false,
|
|
319
|
-
"docs": {
|
|
320
|
-
"tags": [],
|
|
321
|
-
"text": "Auto Slide"
|
|
322
|
-
},
|
|
323
|
-
"attribute": "auto-slide",
|
|
324
|
-
"reflect": false,
|
|
325
|
-
"defaultValue": "false"
|
|
326
|
-
},
|
|
327
|
-
"loopTime": {
|
|
328
|
-
"type": "number",
|
|
329
|
-
"mutable": false,
|
|
330
|
-
"complexType": {
|
|
331
|
-
"original": "number",
|
|
332
|
-
"resolved": "number",
|
|
333
|
-
"references": {}
|
|
334
|
-
},
|
|
335
|
-
"required": false,
|
|
336
|
-
"optional": false,
|
|
337
|
-
"docs": {
|
|
338
|
-
"tags": [],
|
|
339
|
-
"text": "Auto Slide loop time"
|
|
340
|
-
},
|
|
341
|
-
"attribute": "loop-time",
|
|
342
|
-
"reflect": false,
|
|
343
|
-
"defaultValue": "1"
|
|
344
|
-
},
|
|
345
|
-
"autoItemHeight": {
|
|
346
|
-
"type": "boolean",
|
|
347
|
-
"mutable": false,
|
|
348
|
-
"complexType": {
|
|
349
|
-
"original": "boolean",
|
|
350
|
-
"resolved": "boolean",
|
|
351
|
-
"references": {}
|
|
352
|
-
},
|
|
353
|
-
"required": false,
|
|
354
|
-
"optional": false,
|
|
355
|
-
"docs": {
|
|
356
|
-
"tags": [],
|
|
357
|
-
"text": "Auto fill the Item height"
|
|
358
|
-
},
|
|
359
|
-
"attribute": "auto-item-height",
|
|
360
|
-
"reflect": false,
|
|
361
|
-
"defaultValue": "false"
|
|
362
|
-
},
|
|
363
|
-
"clientStyling": {
|
|
364
|
-
"type": "string",
|
|
365
|
-
"mutable": false,
|
|
366
|
-
"complexType": {
|
|
367
|
-
"original": "string",
|
|
368
|
-
"resolved": "string",
|
|
369
|
-
"references": {}
|
|
370
|
-
},
|
|
371
|
-
"required": false,
|
|
372
|
-
"optional": true,
|
|
373
|
-
"docs": {
|
|
374
|
-
"tags": [],
|
|
375
|
-
"text": "Client custom styling via inline styles"
|
|
376
|
-
},
|
|
377
|
-
"attribute": "client-styling",
|
|
378
|
-
"reflect": false,
|
|
379
|
-
"defaultValue": "''"
|
|
380
|
-
},
|
|
381
|
-
"clientStylingUrl": {
|
|
382
|
-
"type": "string",
|
|
383
|
-
"mutable": false,
|
|
384
|
-
"complexType": {
|
|
385
|
-
"original": "string",
|
|
386
|
-
"resolved": "string",
|
|
387
|
-
"references": {}
|
|
388
|
-
},
|
|
389
|
-
"required": false,
|
|
390
|
-
"optional": true,
|
|
391
|
-
"docs": {
|
|
392
|
-
"tags": [],
|
|
393
|
-
"text": "Client custom styling via url"
|
|
394
|
-
},
|
|
395
|
-
"attribute": "client-styling-url",
|
|
396
|
-
"reflect": false,
|
|
397
|
-
"defaultValue": "''"
|
|
115
|
+
getTouches(evt) {
|
|
116
|
+
return evt.touches || evt.originalEvent.touches;
|
|
398
117
|
}
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
118
|
+
handleTouchMove(evt) {
|
|
119
|
+
if (!this.xDown || !this.yDown)
|
|
120
|
+
return;
|
|
121
|
+
let xUp = evt.touches[0].clientX;
|
|
122
|
+
let yUp = evt.touches[0].clientY;
|
|
123
|
+
let xDiff = this.xDown - xUp;
|
|
124
|
+
let yDiff = this.yDown - yUp;
|
|
125
|
+
if (Math.abs(xDiff) > Math.abs(yDiff)) {
|
|
126
|
+
if (xDiff > 0) {
|
|
127
|
+
this.slide(true);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
this.slide(false);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
this.xDown = null;
|
|
134
|
+
this.yDown = null;
|
|
135
|
+
if (this.autoSlide) {
|
|
136
|
+
this.setSlideAutoInterval();
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
;
|
|
140
|
+
setSlideAutoInterval() {
|
|
141
|
+
if (this.loopTime == 0) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
clearInterval(this.sliderInterval);
|
|
145
|
+
this.sliderInterval = setInterval(() => {
|
|
146
|
+
if (this.currentPage + 1 < this.slidesCount / this.slideNumber) {
|
|
147
|
+
this.slideTo(this.currentPage + 1);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
this.slideTo(0);
|
|
151
|
+
}
|
|
152
|
+
}, Number(this.loopTime) * 1000);
|
|
153
|
+
}
|
|
154
|
+
componentDidUpdate() {
|
|
155
|
+
this.sliderEl.style.transform = `translateX(${this.currentSlideNumber * this.slideWidth * -1}px)`;
|
|
156
|
+
this.updateControls();
|
|
157
|
+
}
|
|
158
|
+
switchLoopStatus(isMouseMoveEnter) {
|
|
159
|
+
if (!this.autoSlide)
|
|
160
|
+
return;
|
|
161
|
+
if (this.loopTime > 0) {
|
|
162
|
+
if (isMouseMoveEnter) {
|
|
163
|
+
clearInterval(this.sliderInterval);
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
this.setSlideAutoInterval();
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
setClientStyling() {
|
|
171
|
+
const sheet = new CSSStyleSheet();
|
|
172
|
+
// @ts-ignore
|
|
173
|
+
sheet.replace(this.clientStyling);
|
|
174
|
+
// @ts-ignore
|
|
175
|
+
this.el.shadowRoot.adoptedStyleSheets = [...this.el.shadowRoot.adoptedStyleSheets, sheet];
|
|
176
|
+
}
|
|
177
|
+
setClientStylingURL() {
|
|
178
|
+
let url = new URL(this.clientStylingUrl);
|
|
179
|
+
fetch(url.href)
|
|
180
|
+
.then((res) => res.text())
|
|
181
|
+
.then((data) => {
|
|
182
|
+
const sheet = new CSSStyleSheet();
|
|
183
|
+
// @ts-ignore
|
|
184
|
+
sheet.replace(data);
|
|
185
|
+
// @ts-ignore
|
|
186
|
+
this.el.shadowRoot.adoptedStyleSheets = [...this.el.shadowRoot.adoptedStyleSheets, sheet];
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
render() {
|
|
190
|
+
return (h("div", { key: 'b8c30bef4c9ca004256c94cb642e8acb350afea4', class: "GeneralSlider" }, h("div", { key: '27d6869ae4f675f5e14d17fae20718ec24391e1b', class: "Slider" }, this.showArrow &&
|
|
191
|
+
h("div", { key: '61acebc8e1a0ecf02ae6dad1ecc6f618424d05d5' }, h("button", { key: 'c593883f94b693d6dfe741b2b4ed08185db36ef2', type: "button", class: "Button ButtonNext", onClick: this.slide.bind(this, true), onMouseEnter: this.switchLoopStatus.bind(this, true), onMouseLeave: this.switchLoopStatus.bind(this, false) }, ">"), h("button", { key: '2bea5e3e9f36443e78bc25f0556dce2adb7111a0', type: "button", class: "Button ButtonPrev", onClick: this.slide.bind(this, false), onMouseEnter: this.switchLoopStatus.bind(this, true), onMouseLeave: this.switchLoopStatus.bind(this, false) }, "<")), h("ul", { key: '6643c865256f26b5d06ec78044a2b595832ecb5e', class: `SliderList Col-${this.slideShow}`, part: "SliderList", onMouseEnter: this.switchLoopStatus.bind(this, true), onMouseLeave: this.switchLoopStatus.bind(this, false), ref: (el) => this.sliderEl = el }, h("slot", { key: '48f1ad37b771f32ecc27f3065d58bc7ef1a8a021', ref: (el) => this.slotEl = el }))), this.showButton && this.slidesCount > 0 &&
|
|
192
|
+
h("div", { key: 'd125efa8c68a6e913664d01fb395ed6cada71f5b', class: "PageButtons", part: "PageButtons" }, [...Array(this.slidesCount / this.slideNumber)].map((_x, i) => h("div", { class: `PageButton ${this.currentPage == i ? 'active' : ''}`, title: `page${i}`, onClick: this.slideTo.bind(this, i), onMouseEnter: this.switchLoopStatus.bind(this, true), onMouseLeave: this.switchLoopStatus.bind(this, false) }, "\u00A0")))));
|
|
193
|
+
}
|
|
194
|
+
static get is() { return "general-slider"; }
|
|
195
|
+
static get encapsulation() { return "shadow"; }
|
|
196
|
+
static get originalStyleUrls() {
|
|
197
|
+
return {
|
|
198
|
+
"$": ["general-slider.scss"]
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
static get styleUrls() {
|
|
202
|
+
return {
|
|
203
|
+
"$": ["general-slider.css"]
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
static get properties() {
|
|
207
|
+
return {
|
|
208
|
+
"slideNumber": {
|
|
209
|
+
"type": "number",
|
|
210
|
+
"mutable": false,
|
|
211
|
+
"complexType": {
|
|
212
|
+
"original": "number",
|
|
213
|
+
"resolved": "number",
|
|
214
|
+
"references": {}
|
|
215
|
+
},
|
|
216
|
+
"required": false,
|
|
217
|
+
"optional": false,
|
|
218
|
+
"docs": {
|
|
219
|
+
"tags": [],
|
|
220
|
+
"text": "Slide Count"
|
|
221
|
+
},
|
|
222
|
+
"attribute": "slide-number",
|
|
223
|
+
"reflect": false,
|
|
224
|
+
"defaultValue": "3"
|
|
225
|
+
},
|
|
226
|
+
"slideShow": {
|
|
227
|
+
"type": "number",
|
|
228
|
+
"mutable": false,
|
|
229
|
+
"complexType": {
|
|
230
|
+
"original": "number",
|
|
231
|
+
"resolved": "number",
|
|
232
|
+
"references": {}
|
|
233
|
+
},
|
|
234
|
+
"required": false,
|
|
235
|
+
"optional": false,
|
|
236
|
+
"docs": {
|
|
237
|
+
"tags": [],
|
|
238
|
+
"text": "Slides to show"
|
|
239
|
+
},
|
|
240
|
+
"attribute": "slide-show",
|
|
241
|
+
"reflect": false,
|
|
242
|
+
"defaultValue": "3"
|
|
243
|
+
},
|
|
244
|
+
"showArrow": {
|
|
245
|
+
"type": "boolean",
|
|
246
|
+
"mutable": false,
|
|
247
|
+
"complexType": {
|
|
248
|
+
"original": "boolean",
|
|
249
|
+
"resolved": "boolean",
|
|
250
|
+
"references": {}
|
|
251
|
+
},
|
|
252
|
+
"required": false,
|
|
253
|
+
"optional": false,
|
|
254
|
+
"docs": {
|
|
255
|
+
"tags": [],
|
|
256
|
+
"text": "Display the arrow icon"
|
|
257
|
+
},
|
|
258
|
+
"attribute": "show-arrow",
|
|
259
|
+
"reflect": false,
|
|
260
|
+
"defaultValue": "true"
|
|
261
|
+
},
|
|
262
|
+
"showButton": {
|
|
263
|
+
"type": "boolean",
|
|
264
|
+
"mutable": false,
|
|
265
|
+
"complexType": {
|
|
266
|
+
"original": "boolean",
|
|
267
|
+
"resolved": "boolean",
|
|
268
|
+
"references": {}
|
|
269
|
+
},
|
|
270
|
+
"required": false,
|
|
271
|
+
"optional": false,
|
|
272
|
+
"docs": {
|
|
273
|
+
"tags": [],
|
|
274
|
+
"text": "Display the button"
|
|
275
|
+
},
|
|
276
|
+
"attribute": "show-button",
|
|
277
|
+
"reflect": false,
|
|
278
|
+
"defaultValue": "false"
|
|
279
|
+
},
|
|
280
|
+
"autoSlide": {
|
|
281
|
+
"type": "boolean",
|
|
282
|
+
"mutable": false,
|
|
283
|
+
"complexType": {
|
|
284
|
+
"original": "boolean",
|
|
285
|
+
"resolved": "boolean",
|
|
286
|
+
"references": {}
|
|
287
|
+
},
|
|
288
|
+
"required": false,
|
|
289
|
+
"optional": false,
|
|
290
|
+
"docs": {
|
|
291
|
+
"tags": [],
|
|
292
|
+
"text": "Auto Slide"
|
|
293
|
+
},
|
|
294
|
+
"attribute": "auto-slide",
|
|
295
|
+
"reflect": false,
|
|
296
|
+
"defaultValue": "false"
|
|
297
|
+
},
|
|
298
|
+
"loopTime": {
|
|
299
|
+
"type": "number",
|
|
300
|
+
"mutable": false,
|
|
301
|
+
"complexType": {
|
|
302
|
+
"original": "number",
|
|
303
|
+
"resolved": "number",
|
|
304
|
+
"references": {}
|
|
305
|
+
},
|
|
306
|
+
"required": false,
|
|
307
|
+
"optional": false,
|
|
308
|
+
"docs": {
|
|
309
|
+
"tags": [],
|
|
310
|
+
"text": "Auto Slide loop time"
|
|
311
|
+
},
|
|
312
|
+
"attribute": "loop-time",
|
|
313
|
+
"reflect": false,
|
|
314
|
+
"defaultValue": "1"
|
|
315
|
+
},
|
|
316
|
+
"autoItemHeight": {
|
|
317
|
+
"type": "boolean",
|
|
318
|
+
"mutable": false,
|
|
319
|
+
"complexType": {
|
|
320
|
+
"original": "boolean",
|
|
321
|
+
"resolved": "boolean",
|
|
322
|
+
"references": {}
|
|
323
|
+
},
|
|
324
|
+
"required": false,
|
|
325
|
+
"optional": false,
|
|
326
|
+
"docs": {
|
|
327
|
+
"tags": [],
|
|
328
|
+
"text": "Auto fill the Item height"
|
|
329
|
+
},
|
|
330
|
+
"attribute": "auto-item-height",
|
|
331
|
+
"reflect": false,
|
|
332
|
+
"defaultValue": "false"
|
|
333
|
+
},
|
|
334
|
+
"clientStyling": {
|
|
335
|
+
"type": "string",
|
|
336
|
+
"mutable": false,
|
|
337
|
+
"complexType": {
|
|
338
|
+
"original": "string",
|
|
339
|
+
"resolved": "string",
|
|
340
|
+
"references": {}
|
|
341
|
+
},
|
|
342
|
+
"required": false,
|
|
343
|
+
"optional": true,
|
|
344
|
+
"docs": {
|
|
345
|
+
"tags": [],
|
|
346
|
+
"text": "Client custom styling via inline styles"
|
|
347
|
+
},
|
|
348
|
+
"attribute": "client-styling",
|
|
349
|
+
"reflect": false,
|
|
350
|
+
"defaultValue": "''"
|
|
351
|
+
},
|
|
352
|
+
"clientStylingUrl": {
|
|
353
|
+
"type": "string",
|
|
354
|
+
"mutable": false,
|
|
355
|
+
"complexType": {
|
|
356
|
+
"original": "string",
|
|
357
|
+
"resolved": "string",
|
|
358
|
+
"references": {}
|
|
359
|
+
},
|
|
360
|
+
"required": false,
|
|
361
|
+
"optional": true,
|
|
362
|
+
"docs": {
|
|
363
|
+
"tags": [],
|
|
364
|
+
"text": "Client custom styling via url"
|
|
365
|
+
},
|
|
366
|
+
"attribute": "client-styling-url",
|
|
367
|
+
"reflect": false,
|
|
368
|
+
"defaultValue": "''"
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
static get states() {
|
|
373
|
+
return {
|
|
374
|
+
"currentSlideNumber": {},
|
|
375
|
+
"slidesCount": {},
|
|
376
|
+
"limitStylingAppends": {}
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
static get elementRef() { return "el"; }
|
|
406
380
|
}
|