@everymatrix/casino-tournament-slider 1.19.2 → 1.19.3

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 (22) hide show
  1. package/dist/casino-tournament-slider/casino-tournament-slider.esm.js +1 -1
  2. package/dist/casino-tournament-slider/p-36aa7336.js +1 -0
  3. package/dist/casino-tournament-slider/p-4f990cd8.entry.js +1 -0
  4. package/dist/cjs/casino-tournament-slider.cjs.entry.js +132 -0
  5. package/dist/cjs/casino-tournament-slider.cjs.js +2 -2
  6. package/dist/cjs/{index-f60eba31.js → index-86b08679.js} +1 -15
  7. package/dist/cjs/loader.cjs.js +2 -2
  8. package/dist/collection/collection-manifest.json +1 -8
  9. package/dist/components/casino-tournament-slider.js +2 -7
  10. package/dist/esm/casino-tournament-slider.entry.js +128 -0
  11. package/dist/esm/casino-tournament-slider.js +2 -2
  12. package/dist/esm/{index-c48feefa.js → index-c8b1c9a5.js} +2 -15
  13. package/dist/esm/loader.js +2 -2
  14. package/dist/types/Users/dragos.bodea/Documents/everymatrix-prjs/stencil/widgets-stencil/packages/casino-tournament-slider/.stencil/packages/casino-tournament-slider/stencil.config.d.ts +2 -0
  15. package/package.json +1 -1
  16. package/dist/casino-tournament-slider/p-3af7237d.entry.js +0 -1
  17. package/dist/casino-tournament-slider/p-7bade785.js +0 -1
  18. package/dist/cjs/casino-tournament-slider_2.cjs.entry.js +0 -293
  19. package/dist/components/general-slider.js +0 -6
  20. package/dist/components/general-slider2.js +0 -189
  21. package/dist/esm/casino-tournament-slider_2.entry.js +0 -288
  22. package/dist/types/Users/sebastian.strulea/Documents/work/widgets-stencil/packages/casino-tournament-slider/.stencil/packages/casino-tournament-slider/stencil.config.d.ts +0 -2
@@ -1,293 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const index = require('./index-f60eba31.js');
6
-
7
- const DEFAULT_LANGUAGE = 'en';
8
- const SUPPORTED_LANGUAGES = ['ro', 'en', 'zh-hk', 'fr', 'hu', 'tr', 'el', 'es', 'pt'];
9
- const TRANSLATIONS = {
10
- en: {
11
- playNow: 'Play now',
12
- sliderTitle: 'Participanting games'
13
- },
14
- 'zh-hk': {
15
- playNow: '现在播放',
16
- },
17
- fr: {
18
- playNow: 'Joue maintenant',
19
- },
20
- ro: {
21
- playNow: 'Joaca acum',
22
- },
23
- hu: {
24
- playNow: 'Játsszon most',
25
- },
26
- tr: {
27
- playNow: 'Şimdi oyna',
28
- },
29
- el: {
30
- playNow: 'Παίξε τώρα',
31
- },
32
- es: {
33
- playNow: 'Jugar Ya',
34
- },
35
- pt: {
36
- playNow: 'Jogue agora',
37
- },
38
- };
39
- const translate = (key, customLang) => {
40
- const lang = customLang;
41
- return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
42
- };
43
-
44
- const casinoTournamentSliderCss = ":host{display:block}.Item{color:white;display:flex;justify-content:center;align-items:center;font-weight:bold;font-size:10rem;user-select:none;overflow:hidden}.Item .Img{width:100%;height:100%}.PlayNowButton{position:absolute;background:var(--emfe-w-color-green, #48952a);display:block;box-sizing:border-box;padding:0.8rem 0.5rem;color:var(--emfe-w-color-white, #FFFFFF);text-transform:uppercase;text-align:center;font-weight:600;font-size:0.7rem;cursor:pointer;transition:opacity 0.4s linear;opacity:0;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.ItemHover{opacity:1}.Items .Item:first-child{margin-left:0}.Items .Item:last-child{margin-right:0}.SliderTitle{display:flex;align-items:center;padding:6px 0;gap:11px}.Title{color:#fff;font-size:14px;font-weight:600}";
45
-
46
- const CasinoTournamentSlider = class {
47
- constructor(hostRef) {
48
- index.registerInstance(this, hostRef);
49
- this.gamesLimit = 30;
50
- this.offset = 0;
51
- this.slideNumber = 3;
52
- this.slideShow = 3;
53
- this.clientStyling = '';
54
- this.clientStylingUrl = '';
55
- this.showTitle = false;
56
- this.limitStylingAppends = false;
57
- this.enter = (index) => {
58
- this.hover = true;
59
- this.hoverIndex = index;
60
- };
61
- this.leave = () => {
62
- this.hover = false;
63
- this.hoverIndex = -1;
64
- };
65
- this.gameClicked = (item) => {
66
- window.postMessage({ type: 'TournamentGameAction', gameId: item.id, name: item.name }, window.location.href);
67
- };
68
- this.setClientStyling = () => {
69
- let sheet = document.createElement('style');
70
- sheet.innerHTML = this.clientStyling;
71
- this.stylingContainer.prepend(sheet);
72
- };
73
- this.setClientStylingURL = () => {
74
- let cssFile = document.createElement('style');
75
- setTimeout(() => {
76
- cssFile.innerHTML = this.clientStylingUrl;
77
- this.stylingContainer.prepend(cssFile);
78
- }, 1);
79
- };
80
- }
81
- todoCompletedHandler(event) {
82
- if (event.detail && this.useEvent) {
83
- if (!event.detail.games)
84
- return;
85
- this.games = event.detail.games.items;
86
- }
87
- }
88
- getTournamentInfo() {
89
- let url = new URL(this.endpoint + `/tournaments/${this.tournamentId}`);
90
- let reqHeaders = new Headers();
91
- url.searchParams.append('expand', 'games');
92
- url.searchParams.append('language', this.language);
93
- url.searchParams.append('pagination', `games(limit=${this.gamesLimit},offset=${this.offset})`);
94
- url.searchParams.append('fields', 'games(id,name,thumbnail)');
95
- if (this.session) {
96
- reqHeaders.append('X-SessionId', this.session);
97
- }
98
- let requestOptions = {
99
- method: 'GET',
100
- headers: reqHeaders,
101
- };
102
- fetch(url.href, requestOptions).then((res) => res.json())
103
- .then((res) => {
104
- this.games = res.item.games.items;
105
- });
106
- }
107
- componentWillLoad() {
108
- if (!this.useEvent && this.endpoint && this.tournamentId) {
109
- this.getTournamentInfo();
110
- }
111
- }
112
- componentDidRender() {
113
- if (!this.limitStylingAppends && this.stylingContainer) {
114
- if (this.clientStyling)
115
- this.setClientStyling();
116
- if (this.clientStylingUrl)
117
- this.setClientStylingURL();
118
- this.limitStylingAppends = true;
119
- }
120
- }
121
- render() {
122
- return index.h("div", { ref: el => this.stylingContainer = el }, index.h("div", { class: "TournamentSlider" }, this.showTitle && this.games &&
123
- index.h("div", { class: "SliderTitle" }, index.h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "21", height: "25", viewBox: "0 0 21 25", fill: "none" }, index.h("path", { d: "M6.1774 22.1728C6.36493 22.2725 6.56274 22.0566 6.44793 21.8779C5.82475 20.908 5.23463 19.2759 6.17483 17.174C7.74273 13.6689 8.6968 11.8535 8.6968 11.8535C8.6968 11.8535 9.20426 13.9721 10.5799 15.8558C11.9038 17.6687 12.6285 19.9488 11.4602 21.8482C11.3506 22.0265 11.5439 22.2368 11.7302 22.1415C13.1763 21.4017 14.7983 19.9179 14.9813 16.965C15.0488 16.0627 14.9476 14.7995 14.4416 13.2054C13.791 11.185 12.9911 10.2423 12.5283 9.83741C12.3899 9.71629 12.1746 9.82363 12.1859 10.0072C12.3208 12.1872 11.5007 12.7404 11.0339 11.4937C10.8474 10.9957 10.7387 10.1344 10.7387 9.08558C10.7387 7.3394 10.2321 5.54188 9.1152 4.0812C8.82475 3.70134 8.4849 3.3464 8.09498 3.04372C7.95382 2.93411 7.74919 3.04428 7.76212 3.22252C7.84788 4.40628 7.77018 7.79884 4.79383 11.8519C2.09515 15.6115 3.14088 18.4989 3.51195 19.281C4.2214 20.7791 5.21098 21.6589 6.1774 22.1728Z", fill: "white" })), index.h("span", { class: "Title" }, translate('sliderTitle', this.language))), index.h("div", { class: "Items" }, this.games &&
124
- index.h("general-slider", { "slide-number": this.slideNumber, "slide-show": this.slideShow }, this.games && this.games.map((game, i) => {
125
- return index.h("li", { class: "Item", onMouseEnter: () => this.enter(i), onMouseLeave: () => this.leave() }, index.h("span", { class: `PlayNowButton ${this.hoverIndex == i ? 'ItemHover' : ''}`, onClick: () => { this.gameClicked(game); } }, translate('playNow', this.language)), index.h("img", { class: "Img", src: game.thumbnail, alt: game.name, title: game.name }));
126
- })))));
127
- }
128
- };
129
- CasinoTournamentSlider.style = casinoTournamentSliderCss;
130
-
131
- const generalSliderCss = ":host{display:block}.GeneralSlider{position:relative}.Slider{position:relative;width:100%;margin:0 auto;overflow:hidden}.SliderList{display:flex;margin:0;padding:0;list-style:none;transition:transform 0.5s ease-in-out}::slotted(li){flex:1 0 auto;width:100%;margin:auto}::slotted(li.hide){visibility:hidden;height:0;transition-delay:500ms}.Col-2 ::slotted(li){flex:2 0 auto;width:50%}.Col-3 ::slotted(li){flex:3 0 auto;width:33.3333333333%}.Col-4 ::slotted(li){flex:4 0 auto;width:25%}.Col-5 ::slotted(li){flex:5 0 auto;width:20%}.Col-6 ::slotted(li){flex:6 0 auto;width:16.6666666667%}.Col-7 ::slotted(li){flex:7 0 auto;width:14.2857142857%}.Col-8 ::slotted(li){flex:8 0 auto;width:12.5%}.Col-9 ::slotted(li){flex:9 0 auto;width:11.1111111111%}.Col-10 ::slotted(li){flex:10 0 auto;width:10%}.Col-11 ::slotted(li){flex:11 0 auto;width:9.0909090909%}.Col-12 ::slotted(li){flex:12 0 auto;width:8.3333333333%}.Button{position:absolute;z-index:1;top:calc(50% - 32px);padding:20px;font-size:20px;line-height:20px;opacity:0.5;border:none;background:var(--emfe-w-color-contrast, #07072A);color:var(--emfe-w-color-white, #FFFFFF);cursor:pointer}.Button:hover{opacity:1;transition:opacity 0.5s ease-in-out}.Button[disabled],.Button[disabled]:hover{color:var(--emfe-w-color-gray-150, #828282);opacity:0.25}.Button.ButtonNext{right:0}.PageButtons{display:flex;gap:4px;margin-top:8px}.PageButton{width:15px;height:4px;border-radius:4px;background-color:#0072ED;opacity:0.2;cursor:pointer;float:right}.PageButton.active{width:45px;opacity:1}";
132
-
133
- const GeneralSlider = class {
134
- constructor(hostRef) {
135
- index.registerInstance(this, hostRef);
136
- this.showStatus = false;
137
- this.slideNumber = 3;
138
- this.slideShow = 3;
139
- this.showArrow = true;
140
- this.showButton = false;
141
- this.autoSlide = false;
142
- this.loopTime = 1;
143
- this.autoItemHeight = false;
144
- this.currentSlideNumber = 0;
145
- this.slidesCount = 0;
146
- this.slideWidth = 0;
147
- this.currentPage = 0;
148
- this.controls = {
149
- Prev: null,
150
- Next: null
151
- };
152
- this.xDown = null;
153
- this.yDown = null;
154
- }
155
- slide(next) {
156
- let slideTo = 0;
157
- if (next) {
158
- slideTo = this.currentSlideNumber + this.slideNumber;
159
- }
160
- else {
161
- slideTo = this.currentSlideNumber - this.slideNumber;
162
- }
163
- if (slideTo < 0 || slideTo >= this.slidesCount)
164
- return;
165
- this.currentSlideNumber = slideTo;
166
- this.currentPage = this.currentSlideNumber / this.slideNumber;
167
- this.updateListStyle();
168
- }
169
- slideTo(page) {
170
- this.currentSlideNumber = page * this.slideNumber;
171
- this.currentPage = page;
172
- this.updateListStyle();
173
- }
174
- updateControls() {
175
- this.switchControl('Prev', (this.currentSlideNumber === 0) ? false : true);
176
- this.switchControl('Next', (this.currentSlideNumber === this.slidesCount - this.slideShow) ? false : true);
177
- }
178
- switchControl(type, enabled) {
179
- if (this.controls[type]) {
180
- this.controls[type].disabled = !enabled;
181
- }
182
- }
183
- componentWillLoad() {
184
- this.slides = this.el.querySelectorAll('li');
185
- this.slidesCount = this.slides.length;
186
- if (!this.slideNumber)
187
- this.slideNumber = 1;
188
- if (!this.slideShow)
189
- this.slideShow = 1;
190
- }
191
- componentDidLoad() {
192
- this.sliderList = this.el.shadowRoot.querySelector('ul');
193
- this.slideWidth = this.slides[0].offsetWidth;
194
- for (let type in this.controls) {
195
- this.controls[type] = this.el.shadowRoot.querySelector('.Button' + type);
196
- }
197
- this.updateControls();
198
- if (this.autoSlide) {
199
- this.setSlideAutoInterval();
200
- }
201
- }
202
- componentDidRender() {
203
- this.el.addEventListener('touchstart', this.handleTouchStart.bind(this), { passive: true });
204
- this.el.addEventListener('touchmove', this.handleTouchMove.bind(this), { passive: true });
205
- this.updateListStyle();
206
- }
207
- updateListStyle() {
208
- if (!this.autoItemHeight)
209
- return;
210
- const sliderlist = this.el.querySelectorAll('li');
211
- sliderlist.forEach((li, index) => {
212
- li.classList.add('hide');
213
- if (index >= this.currentPage * this.slideNumber && index < (this.currentPage + 1) * this.slideNumber) {
214
- li.classList.remove('hide');
215
- }
216
- });
217
- }
218
- disconnectedCallback() {
219
- this.el.removeEventListener('touchstart', this.handleTouchStart);
220
- this.el.removeEventListener('touchmove', this.handleTouchMove);
221
- }
222
- handleTouchStart(evt) {
223
- const firstTouch = this.getTouches(evt)[0];
224
- this.xDown = firstTouch.clientX;
225
- this.yDown = firstTouch.clientY;
226
- clearInterval(this.sliderInterval);
227
- }
228
- getTouches(evt) {
229
- return evt.touches || evt.originalEvent.touches;
230
- }
231
- handleTouchMove(evt) {
232
- if (!this.xDown || !this.yDown)
233
- return;
234
- let xUp = evt.touches[0].clientX;
235
- let yUp = evt.touches[0].clientY;
236
- let xDiff = this.xDown - xUp;
237
- let yDiff = this.yDown - yUp;
238
- if (Math.abs(xDiff) > Math.abs(yDiff)) {
239
- if (xDiff > 0) {
240
- this.slide(true);
241
- }
242
- else {
243
- this.slide(false);
244
- }
245
- }
246
- this.xDown = null;
247
- this.yDown = null;
248
- if (this.autoSlide) {
249
- this.setSlideAutoInterval();
250
- }
251
- }
252
- ;
253
- setSlideAutoInterval() {
254
- if (this.loopTime == 0) {
255
- return;
256
- }
257
- clearInterval(this.sliderInterval);
258
- this.sliderInterval = setInterval(() => {
259
- if (this.currentPage + 1 < this.slidesCount / this.slideNumber) {
260
- this.slideTo(this.currentPage + 1);
261
- }
262
- else {
263
- this.slideTo(0);
264
- }
265
- }, Number(this.loopTime) * 1000);
266
- }
267
- componentDidUpdate() {
268
- this.sliderList.style.transform = `translateX(${this.currentSlideNumber * this.slideWidth * -1}px)`;
269
- this.updateControls();
270
- }
271
- switchLoopStatus(isMouseMoveEnter) {
272
- if (!this.autoSlide)
273
- return;
274
- if (this.loopTime > 0) {
275
- if (isMouseMoveEnter) {
276
- clearInterval(this.sliderInterval);
277
- }
278
- else {
279
- this.setSlideAutoInterval();
280
- }
281
- }
282
- }
283
- render() {
284
- return (index.h("div", { class: "GeneralSlider" }, index.h("div", { class: "Slider" }, this.showArrow &&
285
- index.h("div", null, index.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) }, ">"), index.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) }, "<")), index.h("ul", { class: `SliderList Col-${this.slideShow}`, part: "SliderList", onMouseEnter: this.switchLoopStatus.bind(this, true), onMouseLeave: this.switchLoopStatus.bind(this, false) }, index.h("slot", null))), this.showButton && this.slidesCount > 0 &&
286
- index.h("div", { class: "PageButtons", part: "PageButtons" }, [...Array(this.slidesCount / this.slideNumber)].map((_x, i) => index.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")))));
287
- }
288
- get el() { return index.getElement(this); }
289
- };
290
- GeneralSlider.style = generalSliderCss;
291
-
292
- exports.casino_tournament_slider = CasinoTournamentSlider;
293
- exports.general_slider = GeneralSlider;
@@ -1,6 +0,0 @@
1
- import { G as GeneralSlider$1, d as defineCustomElement$1 } from './general-slider2.js';
2
-
3
- const GeneralSlider = GeneralSlider$1;
4
- const defineCustomElement = defineCustomElement$1;
5
-
6
- export { GeneralSlider, defineCustomElement };
@@ -1,189 +0,0 @@
1
- import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
2
-
3
- const generalSliderCss = ":host{display:block}.GeneralSlider{position:relative}.Slider{position:relative;width:100%;margin:0 auto;overflow:hidden}.SliderList{display:flex;margin:0;padding:0;list-style:none;transition:transform 0.5s ease-in-out}::slotted(li){flex:1 0 auto;width:100%;margin:auto}::slotted(li.hide){visibility:hidden;height:0;transition-delay:500ms}.Col-2 ::slotted(li){flex:2 0 auto;width:50%}.Col-3 ::slotted(li){flex:3 0 auto;width:33.3333333333%}.Col-4 ::slotted(li){flex:4 0 auto;width:25%}.Col-5 ::slotted(li){flex:5 0 auto;width:20%}.Col-6 ::slotted(li){flex:6 0 auto;width:16.6666666667%}.Col-7 ::slotted(li){flex:7 0 auto;width:14.2857142857%}.Col-8 ::slotted(li){flex:8 0 auto;width:12.5%}.Col-9 ::slotted(li){flex:9 0 auto;width:11.1111111111%}.Col-10 ::slotted(li){flex:10 0 auto;width:10%}.Col-11 ::slotted(li){flex:11 0 auto;width:9.0909090909%}.Col-12 ::slotted(li){flex:12 0 auto;width:8.3333333333%}.Button{position:absolute;z-index:1;top:calc(50% - 32px);padding:20px;font-size:20px;line-height:20px;opacity:0.5;border:none;background:var(--emfe-w-color-contrast, #07072A);color:var(--emfe-w-color-white, #FFFFFF);cursor:pointer}.Button:hover{opacity:1;transition:opacity 0.5s ease-in-out}.Button[disabled],.Button[disabled]:hover{color:var(--emfe-w-color-gray-150, #828282);opacity:0.25}.Button.ButtonNext{right:0}.PageButtons{display:flex;gap:4px;margin-top:8px}.PageButton{width:15px;height:4px;border-radius:4px;background-color:#0072ED;opacity:0.2;cursor:pointer;float:right}.PageButton.active{width:45px;opacity:1}";
4
-
5
- const GeneralSlider = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
6
- constructor() {
7
- super();
8
- this.__registerHost();
9
- this.__attachShadow();
10
- this.showStatus = false;
11
- this.slideNumber = 3;
12
- this.slideShow = 3;
13
- this.showArrow = true;
14
- this.showButton = false;
15
- this.autoSlide = false;
16
- this.loopTime = 1;
17
- this.autoItemHeight = false;
18
- this.currentSlideNumber = 0;
19
- this.slidesCount = 0;
20
- this.slideWidth = 0;
21
- this.currentPage = 0;
22
- this.controls = {
23
- Prev: null,
24
- Next: null
25
- };
26
- this.xDown = null;
27
- this.yDown = null;
28
- }
29
- slide(next) {
30
- let slideTo = 0;
31
- if (next) {
32
- slideTo = this.currentSlideNumber + this.slideNumber;
33
- }
34
- else {
35
- slideTo = this.currentSlideNumber - this.slideNumber;
36
- }
37
- if (slideTo < 0 || slideTo >= this.slidesCount)
38
- return;
39
- this.currentSlideNumber = slideTo;
40
- this.currentPage = this.currentSlideNumber / this.slideNumber;
41
- this.updateListStyle();
42
- }
43
- slideTo(page) {
44
- this.currentSlideNumber = page * this.slideNumber;
45
- this.currentPage = page;
46
- this.updateListStyle();
47
- }
48
- updateControls() {
49
- this.switchControl('Prev', (this.currentSlideNumber === 0) ? false : true);
50
- this.switchControl('Next', (this.currentSlideNumber === this.slidesCount - this.slideShow) ? false : true);
51
- }
52
- switchControl(type, enabled) {
53
- if (this.controls[type]) {
54
- this.controls[type].disabled = !enabled;
55
- }
56
- }
57
- componentWillLoad() {
58
- this.slides = this.el.querySelectorAll('li');
59
- this.slidesCount = this.slides.length;
60
- if (!this.slideNumber)
61
- this.slideNumber = 1;
62
- if (!this.slideShow)
63
- this.slideShow = 1;
64
- }
65
- componentDidLoad() {
66
- this.sliderList = this.el.shadowRoot.querySelector('ul');
67
- this.slideWidth = this.slides[0].offsetWidth;
68
- for (let type in this.controls) {
69
- this.controls[type] = this.el.shadowRoot.querySelector('.Button' + type);
70
- }
71
- this.updateControls();
72
- if (this.autoSlide) {
73
- this.setSlideAutoInterval();
74
- }
75
- }
76
- componentDidRender() {
77
- this.el.addEventListener('touchstart', this.handleTouchStart.bind(this), { passive: true });
78
- this.el.addEventListener('touchmove', this.handleTouchMove.bind(this), { passive: true });
79
- this.updateListStyle();
80
- }
81
- updateListStyle() {
82
- if (!this.autoItemHeight)
83
- return;
84
- const sliderlist = this.el.querySelectorAll('li');
85
- sliderlist.forEach((li, index) => {
86
- li.classList.add('hide');
87
- if (index >= this.currentPage * this.slideNumber && index < (this.currentPage + 1) * this.slideNumber) {
88
- li.classList.remove('hide');
89
- }
90
- });
91
- }
92
- disconnectedCallback() {
93
- this.el.removeEventListener('touchstart', this.handleTouchStart);
94
- this.el.removeEventListener('touchmove', this.handleTouchMove);
95
- }
96
- handleTouchStart(evt) {
97
- const firstTouch = this.getTouches(evt)[0];
98
- this.xDown = firstTouch.clientX;
99
- this.yDown = firstTouch.clientY;
100
- clearInterval(this.sliderInterval);
101
- }
102
- getTouches(evt) {
103
- return evt.touches || evt.originalEvent.touches;
104
- }
105
- handleTouchMove(evt) {
106
- if (!this.xDown || !this.yDown)
107
- return;
108
- let xUp = evt.touches[0].clientX;
109
- let yUp = evt.touches[0].clientY;
110
- let xDiff = this.xDown - xUp;
111
- let yDiff = this.yDown - yUp;
112
- if (Math.abs(xDiff) > Math.abs(yDiff)) {
113
- if (xDiff > 0) {
114
- this.slide(true);
115
- }
116
- else {
117
- this.slide(false);
118
- }
119
- }
120
- this.xDown = null;
121
- this.yDown = null;
122
- if (this.autoSlide) {
123
- this.setSlideAutoInterval();
124
- }
125
- }
126
- ;
127
- setSlideAutoInterval() {
128
- if (this.loopTime == 0) {
129
- return;
130
- }
131
- clearInterval(this.sliderInterval);
132
- this.sliderInterval = setInterval(() => {
133
- if (this.currentPage + 1 < this.slidesCount / this.slideNumber) {
134
- this.slideTo(this.currentPage + 1);
135
- }
136
- else {
137
- this.slideTo(0);
138
- }
139
- }, Number(this.loopTime) * 1000);
140
- }
141
- componentDidUpdate() {
142
- this.sliderList.style.transform = `translateX(${this.currentSlideNumber * this.slideWidth * -1}px)`;
143
- this.updateControls();
144
- }
145
- switchLoopStatus(isMouseMoveEnter) {
146
- if (!this.autoSlide)
147
- return;
148
- if (this.loopTime > 0) {
149
- if (isMouseMoveEnter) {
150
- clearInterval(this.sliderInterval);
151
- }
152
- else {
153
- this.setSlideAutoInterval();
154
- }
155
- }
156
- }
157
- render() {
158
- return (h("div", { class: "GeneralSlider" }, h("div", { class: "Slider" }, this.showArrow &&
159
- h("div", null, 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) }, ">"), 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) }, "<")), h("ul", { class: `SliderList Col-${this.slideShow}`, part: "SliderList", onMouseEnter: this.switchLoopStatus.bind(this, true), onMouseLeave: this.switchLoopStatus.bind(this, false) }, h("slot", null))), this.showButton && this.slidesCount > 0 &&
160
- 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")))));
161
- }
162
- get el() { return this; }
163
- static get style() { return generalSliderCss; }
164
- }, [1, "general-slider", {
165
- "showStatus": [4, "show-status"],
166
- "slideNumber": [2, "slide-number"],
167
- "slideShow": [2, "slide-show"],
168
- "showArrow": [4, "show-arrow"],
169
- "showButton": [4, "show-button"],
170
- "autoSlide": [4, "auto-slide"],
171
- "loopTime": [2, "loop-time"],
172
- "autoItemHeight": [4, "auto-item-height"],
173
- "currentSlideNumber": [32]
174
- }]);
175
- function defineCustomElement() {
176
- if (typeof customElements === "undefined") {
177
- return;
178
- }
179
- const components = ["general-slider"];
180
- components.forEach(tagName => { switch (tagName) {
181
- case "general-slider":
182
- if (!customElements.get(tagName)) {
183
- customElements.define(tagName, GeneralSlider);
184
- }
185
- break;
186
- } });
187
- }
188
-
189
- export { GeneralSlider as G, defineCustomElement as d };