@everymatrix/casino-slider 0.0.392 → 0.0.394
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/casino-slider.js +1 -1
- package/dist/casino-slider.js.map +1 -1
- package/package.json +2 -2
- package/src/CasinoSlider.svelte +280 -86
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@everymatrix/casino-slider",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.394",
|
4
4
|
"main": "dist/casino-slider.js",
|
5
5
|
"svelte": "src/index.ts",
|
6
6
|
"scripts": {
|
@@ -36,5 +36,5 @@
|
|
36
36
|
"publishConfig": {
|
37
37
|
"access": "public"
|
38
38
|
},
|
39
|
-
"gitHead": "
|
39
|
+
"gitHead": "74359bffcfcd357bb93adb3f4cbcd7badbc96fae"
|
40
40
|
}
|
package/src/CasinoSlider.svelte
CHANGED
@@ -7,8 +7,6 @@
|
|
7
7
|
import { _, addNewMessages, setLocale, setupI18n } from './i18n';
|
8
8
|
import { CasinoSlider } from './translations';
|
9
9
|
|
10
|
-
import '@everymatrix/casino-slider-dropdown';
|
11
|
-
|
12
10
|
export let endpoint:string = '';
|
13
11
|
export let datasource:string = '';
|
14
12
|
|
@@ -24,7 +22,7 @@
|
|
24
22
|
export let issecondarymenu:boolean = false;
|
25
23
|
export let lang:string = '';
|
26
24
|
export let activeindex:string = '0';
|
27
|
-
export let showsubgroups:string = '';
|
25
|
+
export let showsubgroups:string = 'false';
|
28
26
|
|
29
27
|
setupI18n({ withLocale: 'en', translations: {}});
|
30
28
|
|
@@ -40,29 +38,38 @@
|
|
40
38
|
let prevIndex:number;
|
41
39
|
let customStylingContainer:HTMLElement;
|
42
40
|
let sliderdata:Array<any> = [];
|
41
|
+
let subGroupsData: any;
|
42
|
+
let itemsActive:Array<boolean> = [];
|
43
|
+
let scroller:HTMLElement;
|
43
44
|
|
44
45
|
// Clicking on the slider item will trigger this method and send a postmessage on window
|
45
46
|
// @TODO itemId type fix
|
46
47
|
let handleClick = (item:any, index:number):void => {
|
48
|
+
scrollHandler();
|
47
49
|
activeIndex = index;
|
48
50
|
activeIndex = activeIndex;
|
49
51
|
prevIndex = activeIndex;
|
50
|
-
|
51
|
-
window.postMessage({ type: actionevent, itemId: item.id, index, item }, window.location.href);
|
52
|
+
getSubGroups(item, index, 'navigation');
|
52
53
|
};
|
53
54
|
|
54
55
|
let scrollLeft = ():void => {
|
55
|
-
|
56
|
+
scroller.scrollBy({
|
56
57
|
left: -250,
|
57
58
|
behavior: 'smooth'
|
58
59
|
});
|
60
|
+
if(showsubgroups == 'true') {
|
61
|
+
obtainSubcategories();
|
62
|
+
}
|
59
63
|
}
|
60
64
|
|
61
65
|
let scrollRight = ():void => {
|
62
|
-
|
66
|
+
scroller.scrollBy({
|
63
67
|
left: +250,
|
64
68
|
behavior: 'smooth'
|
65
69
|
});
|
70
|
+
if(showsubgroups == 'true') {
|
71
|
+
obtainSubcategories();
|
72
|
+
}
|
66
73
|
}
|
67
74
|
|
68
75
|
const setActiveIndex = ():void => {
|
@@ -70,6 +77,9 @@
|
|
70
77
|
if (!prevIndex) {
|
71
78
|
prevIndex = activeIndex;
|
72
79
|
}
|
80
|
+
if(showsubgroups == 'true') {
|
81
|
+
obtainSubcategories();
|
82
|
+
}
|
73
83
|
}
|
74
84
|
|
75
85
|
const setClientStyling = ():void => {
|
@@ -87,7 +97,6 @@
|
|
87
97
|
.then((res:any) => res.text())
|
88
98
|
.then((data:any) => {
|
89
99
|
cssFile.innerHTML = data
|
90
|
-
|
91
100
|
setTimeout(() => { customStylingContainer.appendChild(cssFile); }, 1);
|
92
101
|
});
|
93
102
|
}
|
@@ -96,6 +105,10 @@
|
|
96
105
|
const messageHandler = (e:any):void => {
|
97
106
|
if (e.data.type == 'SliderData' && e.data.identity == identity) {
|
98
107
|
sliderdata = e.data.data;
|
108
|
+
itemsActive = new Array(sliderdata.length).fill(false);
|
109
|
+
if(showsubgroups == 'true') {
|
110
|
+
obtainSubcategories();
|
111
|
+
}
|
99
112
|
}
|
100
113
|
}
|
101
114
|
|
@@ -103,11 +116,63 @@
|
|
103
116
|
setLocale(lang);
|
104
117
|
}
|
105
118
|
|
119
|
+
const getSubGroups = (item:string, index?:number, trigger?:string):void => {
|
120
|
+
if(location == 'secondaryMenu' && endpoint && datasource && lang && item.id) {
|
121
|
+
|
122
|
+
let url:URL = new URL(`${endpoint}/casino/groups/${datasource}/${item.id}/subGroups?language=${lang}`);
|
123
|
+
fetch(url.href)
|
124
|
+
.then((res:any) => res.json())
|
125
|
+
.then((data:any) => {
|
126
|
+
subGroupsData = data;
|
127
|
+
if(showsubgroups == 'false') {
|
128
|
+
window.postMessage({ type: actionevent, itemId: item.id, index, item }, window.location.href);
|
129
|
+
} else {
|
130
|
+
if(trigger == 'navigation' && subGroupsData.count <= 0) {
|
131
|
+
window.postMessage({ type: actionevent, itemId: item.id, index, item }, window.location.href);
|
132
|
+
}
|
133
|
+
}
|
134
|
+
|
135
|
+
}).then(() => {
|
136
|
+
if(carousel.querySelectorAll(".DropDown")) scrollHandler();
|
137
|
+
});
|
138
|
+
}
|
139
|
+
}
|
140
|
+
|
141
|
+
/* Listen for scroll */
|
142
|
+
const scrollHandler = () => {
|
143
|
+
const dropDown = carousel.querySelectorAll(".DropDown");
|
144
|
+
(document.activeElement as HTMLElement).blur();
|
145
|
+
|
146
|
+
scroller.classList.add("isScrolling");
|
147
|
+
for (let i = 0; i < dropDown.length; i++) {
|
148
|
+
dropDown[i].style.transform = "translateX(-" + scroller.scrollLeft + "px)";
|
149
|
+
}
|
150
|
+
scroller.classList.remove("isScrolling");
|
151
|
+
}
|
152
|
+
|
153
|
+
const obtainSubcategories = () => {
|
154
|
+
sliderdata.forEach((category, index) => {
|
155
|
+
if(category?.subGroups?.count > 0) {
|
156
|
+
itemsActive[index] = true;
|
157
|
+
getSubGroups(category, index);
|
158
|
+
}
|
159
|
+
});
|
160
|
+
}
|
161
|
+
|
106
162
|
onMount(() => {
|
163
|
+
if ("ontouchstart" in document.documentElement) {
|
164
|
+
document.documentElement.className += " touch-device";
|
165
|
+
}
|
166
|
+
|
107
167
|
window.addEventListener('message', messageHandler, false);
|
108
168
|
|
169
|
+
setTimeout(() => {
|
170
|
+
scroller.addEventListener('scroll', scrollHandler);
|
171
|
+
}, 500);
|
172
|
+
|
109
173
|
return () => {
|
110
174
|
window.removeEventListener('message', messageHandler);
|
175
|
+
carousel.removeEventListener('scroll', scrollHandler);
|
111
176
|
}
|
112
177
|
})
|
113
178
|
|
@@ -118,38 +183,48 @@
|
|
118
183
|
</script>
|
119
184
|
|
120
185
|
<div class="CarouselWrapper { (location === 'headerMain') ? 'CarouselWrapperHeaderMain' : '' }" part="CarouselWrapper { (location === 'headerMain') ? 'CarouselWrapperHeaderMain' : '' }" bind:this={customStylingContainer}>
|
121
|
-
<div class="CarouselContainer
|
186
|
+
<div class="CarouselContainer CarouselContainerMobile} { (location === 'headerMain') ? 'CarouselContainerHeaderMain' : '' }" part="CarouselContainer {isMobile ? 'CarouselContainerMobile' : ''} { (location === 'headerMain') ? 'CarouselContainerHeaderMain' : '' }" style="{ (location === 'headerMain') ? 'max-width: auto' : `max-width: ${containermaxwidth}px` }">
|
122
187
|
<div class="CarouselLeftArrow" part="CarouselLeftArrow" on:click="{() => scrollLeft()}">
|
123
188
|
<svg fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
124
189
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"></path>
|
125
190
|
</svg>
|
126
191
|
</div>
|
192
|
+
|
193
|
+
<div class="CarouselNavWrap" bind:this={scroller}>
|
194
|
+
<ul id="CarouselNav" class="CarouselItems" part="CarouselItems" bind:this={carousel}>
|
195
|
+
<li class="TouchOnly"><a href="#CarouselNav">Close Subs</a></li>
|
196
|
+
{#if sliderdata.length > 0}
|
197
|
+
{#each sliderdata as category, index (category.id)}
|
198
|
+
<li class="CarouselItem {activeIndex == index || prevIndex == index ? 'active': ''}"
|
199
|
+
part="CarouselItem"
|
200
|
+
on:click={e => { handleClick(category, index); e.preventDefault()}}>
|
201
|
+
{#if location === 'headerMain'}
|
202
|
+
<a href="#">{category.label}</a>
|
203
|
+
{:else}
|
204
|
+
<a href="#">{category.name} {category.id === "FAVORITES" ? "(" + favoritesnumber + ")" : ''}</a>
|
205
|
+
{/if}
|
206
|
+
{#if itemsActive[index] == true}
|
207
|
+
{#if subGroupsData?.count > 0}
|
208
|
+
{#if subGroupsData && showsubgroups == 'true'}
|
209
|
+
<ul class="DropDown">
|
210
|
+
{#each subGroupsData?.items as subGroupsData}
|
211
|
+
{#if subGroupsData.games.count}
|
212
|
+
<li on:click={e => { handleClick(subGroupsData, index); e.stopPropagation();}}>
|
213
|
+
<a href="#">{subGroupsData?.name}</a>
|
214
|
+
</li>
|
215
|
+
{/if}
|
216
|
+
{/each}
|
217
|
+
</ul>
|
218
|
+
{/if}
|
219
|
+
{/if}
|
220
|
+
{/if}
|
221
|
+
|
222
|
+
</li>
|
223
|
+
{/each}
|
224
|
+
{/if}
|
225
|
+
</ul>
|
226
|
+
</div>
|
127
227
|
|
128
|
-
|
129
|
-
<ul class="CarouselItems" part="CarouselItems" bind:this={carousel}>
|
130
|
-
{#if sliderdata.length > 0}
|
131
|
-
{#each sliderdata as category, index (category.id)}
|
132
|
-
<li class="CarouselItem {activeIndex == index || prevIndex == index ? 'active': ''}" part="CarouselItem" on:click={e => handleClick(category, index)}
|
133
|
-
>
|
134
|
-
{#if location === 'headerMain'}
|
135
|
-
<a>{category.label}</a>
|
136
|
-
{:else}
|
137
|
-
{category.name} {category.id === "FAVORITES" ? "(" + favoritesnumber + ")" : ''}
|
138
|
-
{/if}
|
139
|
-
<casino-slider-dropdown
|
140
|
-
{favoritesnumber}
|
141
|
-
categoryid={category.id}
|
142
|
-
{showsubgroups}
|
143
|
-
{location}
|
144
|
-
{endpoint}
|
145
|
-
{lang}
|
146
|
-
{datasource}
|
147
|
-
>
|
148
|
-
</casino-slider-dropdown>
|
149
|
-
</li>
|
150
|
-
{/each}
|
151
|
-
{/if}
|
152
|
-
</ul>
|
153
228
|
<div class="CarouselRightArrow" part="CarouselRightArrow" on:click="{() => scrollRight()}">
|
154
229
|
<svg fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
155
230
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"></path>
|
@@ -158,8 +233,6 @@
|
|
158
233
|
</div>
|
159
234
|
</div>
|
160
235
|
|
161
|
-
|
162
|
-
|
163
236
|
<style lang="scss">
|
164
237
|
|
165
238
|
:host {
|
@@ -193,72 +266,74 @@
|
|
193
266
|
padding: 0;
|
194
267
|
}
|
195
268
|
|
196
|
-
|
197
|
-
position: relative;
|
198
|
-
display: flex;
|
199
|
-
flex-direction: row;
|
200
|
-
flex-wrap: nowrap;
|
269
|
+
ul {
|
201
270
|
align-items: center;
|
202
|
-
overflow-y: scroll;
|
203
|
-
list-style-type: none;
|
204
|
-
-ms-overflow-style: none;
|
205
|
-
scrollbar-width: none;
|
206
271
|
|
207
272
|
&::-webkit-scrollbar {
|
208
273
|
display: none;
|
209
274
|
}
|
210
|
-
|
211
|
-
.CarouselItem {
|
212
|
-
position: relative;
|
213
|
-
display: flex;
|
275
|
+
li {
|
214
276
|
height: 100%;
|
215
277
|
align-items: center;
|
216
|
-
padding: 13px 11px;
|
217
278
|
font-size: 15px;
|
218
279
|
font-weight: 500;
|
219
|
-
text-align: center;
|
220
280
|
line-height: 26px;
|
221
|
-
transition: all 150ms ease-in-out;
|
222
281
|
white-space: nowrap;
|
223
|
-
|
282
|
+
display: inline-block;
|
283
|
+
text-align: left;
|
284
|
+
word-spacing: normal;
|
285
|
+
> a {
|
286
|
+
position: relative;
|
287
|
+
}
|
224
288
|
&:hover,
|
225
|
-
&.active
|
289
|
+
&.active,
|
290
|
+
&:focus,
|
291
|
+
&:focus-within {
|
226
292
|
background: var(--emfe-w-color-contrast, #07072A);
|
227
293
|
cursor: pointer;
|
228
|
-
casino-slider-dropdown {
|
229
|
-
display: block;
|
230
|
-
}
|
231
294
|
}
|
232
|
-
|
233
|
-
|
295
|
+
}
|
296
|
+
li > a {
|
297
|
+
position: relative;
|
234
298
|
}
|
235
299
|
}
|
236
300
|
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
top: 52px;
|
243
|
-
left: 0;
|
244
|
-
padding: 10px 11px;
|
245
|
-
background: var(--emfe-w-color-contrast, #07072A); /* fallback for old browsers */
|
246
|
-
background: -webkit-linear-gradient(var(--emfe-w-color-contrast, #07072A), var(--emfe-w-color-primary, #D0046C)); /* Chrome 10-25, Safari 5.1-6 */
|
247
|
-
background: linear-gradient(var(--emfe-w-color-contrast, #07072A), var(--emfe-w-color-primary, #D0046C)); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
|
248
|
-
& a {
|
249
|
-
display: block;
|
250
|
-
font-weight: 400;
|
251
|
-
line-height: 30px;
|
252
|
-
text-align: left;
|
253
|
-
}
|
301
|
+
ul li:hover,
|
302
|
+
ul > li > a:hover,
|
303
|
+
ul li:focus,
|
304
|
+
ul > li > a:focus {
|
305
|
+
z-index: 105;
|
254
306
|
}
|
255
307
|
|
256
|
-
.
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
308
|
+
.CarouselItems li:hover > ul {
|
309
|
+
left: auto;
|
310
|
+
top: auto;
|
311
|
+
opacity: 1;
|
312
|
+
transition: opacity 0.5s linear, top 0.5s;
|
313
|
+
}
|
314
|
+
.CarouselItems li:focus-within > ul {
|
315
|
+
left: auto;
|
316
|
+
top: auto;
|
317
|
+
opacity: 1;
|
318
|
+
transition: opacity 0.5s linear, top 0.5s;
|
319
|
+
}
|
320
|
+
.CarouselItems ul ul {
|
321
|
+
transition: opacity 0.4s, left 0s 0.4s, margin 0s 0.4s;
|
322
|
+
z-index: 103;
|
323
|
+
}
|
324
|
+
.CarouselItems li li:hover ul {
|
325
|
+
top: auto;
|
326
|
+
margin-left: 100%;
|
327
|
+
transform: translateY(-2.2rem);
|
328
|
+
opacity: 1;
|
329
|
+
transition: opacity 0.5s linear, margin 0.5s;
|
330
|
+
}
|
331
|
+
.CarouselItems li li:focus-within ul {
|
332
|
+
top: auto;
|
333
|
+
margin-left: 100%;
|
334
|
+
transform: translateY(-2.2rem);
|
335
|
+
opacity: 1;
|
336
|
+
transition: opacity 0.5s linear, margin 0.5s;
|
262
337
|
}
|
263
338
|
|
264
339
|
.CarouselLeftArrow,
|
@@ -274,17 +349,94 @@
|
|
274
349
|
width: 100%;
|
275
350
|
max-width: 39px;
|
276
351
|
}
|
352
|
+
}
|
277
353
|
|
278
|
-
|
279
|
-
|
354
|
+
h1 {
|
355
|
+
text-align: center;
|
356
|
+
}
|
357
|
+
ul {
|
358
|
+
margin: 0;
|
359
|
+
padding: 0;
|
360
|
+
list-style: none;
|
361
|
+
}
|
362
|
+
.CarouselNavWrap {
|
363
|
+
overflow-y: scroll;
|
364
|
+
white-space: nowrap;
|
365
|
+
list-style-type: none;
|
366
|
+
-ms-overflow-style: none;
|
367
|
+
scrollbar-width: none;
|
368
|
+
&::-webkit-scrollbar {
|
369
|
+
display: none;
|
280
370
|
}
|
281
371
|
}
|
372
|
+
|
373
|
+
.CarouselItems {
|
374
|
+
display: table; /* White-space fix */
|
375
|
+
width: 100%;
|
376
|
+
text-align: center;
|
377
|
+
li {
|
378
|
+
display: inline-block;
|
379
|
+
text-align: left;
|
380
|
+
& > a {
|
381
|
+
position: relative;
|
382
|
+
}
|
383
|
+
|
384
|
+
li {
|
385
|
+
display: block;
|
386
|
+
}
|
387
|
+
}
|
388
|
+
a {
|
389
|
+
display: block;
|
390
|
+
padding: 7px 10px;
|
391
|
+
color: var(--emfe-w-color-white, #FFFFFF);
|
392
|
+
text-decoration: none;
|
393
|
+
white-space: nowrap;
|
394
|
+
position: relative;
|
395
|
+
}
|
396
|
+
li:hover > a,
|
397
|
+
a:hover,
|
398
|
+
li:focus > a,
|
399
|
+
a:focus {
|
400
|
+
background: var(--emfe-w-color-contrast, #07072A);
|
401
|
+
}
|
402
|
+
ul {
|
403
|
+
position: absolute;
|
404
|
+
z-index: 104;
|
405
|
+
left: -999em;
|
406
|
+
top: 0;
|
407
|
+
opacity: 0;
|
408
|
+
transition: opacity 0.1s, left 0s 0.1s, top 0.1s;
|
409
|
+
background: var(--emfe-w-color-primary, #D0046C);
|
410
|
+
}
|
411
|
+
}
|
412
|
+
|
413
|
+
/* Allow touch to play */
|
414
|
+
.CarouselItems .TouchOnly {
|
415
|
+
display: none;
|
416
|
+
left: -10px;
|
417
|
+
}
|
418
|
+
.touch-device .CarouselItems .TouchOnly {
|
419
|
+
display: inline-block;
|
420
|
+
}
|
421
|
+
.touch-device .CarouselItems .TouchOnly a {
|
422
|
+
background: var(--emfe-w-color-contrast, #07072A);
|
423
|
+
color: var(--emfe-w-color-white, #FFFFFF);
|
424
|
+
}
|
425
|
+
|
426
|
+
/* Remove hover when scrolling */
|
427
|
+
.isScrolling .CarouselItems ul.DropDown{
|
428
|
+
left: -999em;
|
429
|
+
opacity:0;
|
430
|
+
}
|
282
431
|
}
|
283
432
|
|
284
433
|
.CarouselContainerHeaderMain {
|
285
434
|
.CarouselItems .CarouselItem {
|
286
|
-
&:hover,
|
287
|
-
|
435
|
+
&:hover,
|
436
|
+
&.active,
|
437
|
+
&:focus,
|
438
|
+
&:focus-within {
|
439
|
+
background: var(--emfe-w-color-primary, #D0046C);;
|
288
440
|
a {
|
289
441
|
border-bottom: 1px solid var(--emfe-w-color-primary, #D0046C);
|
290
442
|
line-height: 84px;
|
@@ -314,6 +466,47 @@
|
|
314
466
|
}
|
315
467
|
}
|
316
468
|
|
469
|
+
|
470
|
+
/* Arrows */
|
471
|
+
.CarouselItems {
|
472
|
+
li a:first-child:not(:last-child) {
|
473
|
+
padding-right: 20px; /* make space for arrows*/
|
474
|
+
}
|
475
|
+
li a:first-child:not(:last-child):after {
|
476
|
+
content: "";
|
477
|
+
position: absolute;
|
478
|
+
right: 3px;
|
479
|
+
top: 50%;
|
480
|
+
margin-top: -6px;
|
481
|
+
width: 0;
|
482
|
+
height: 0;
|
483
|
+
border-top: 6px solid transparent;
|
484
|
+
border-bottom: 6px solid transparent;
|
485
|
+
border-left: 6px solid var(--emfe-w-color-white, #FFFFFF);
|
486
|
+
}
|
487
|
+
&> li > a:first-child:not(:last-child):after {
|
488
|
+
border-left: 6px solid transparent;
|
489
|
+
border-right: 6px solid transparent;
|
490
|
+
border-top: 6px solid var(--emfe-w-color-white, #FFFFFF);
|
491
|
+
border-bottom: none;
|
492
|
+
margin-top: -3px;
|
493
|
+
}
|
494
|
+
li:hover a:first-child:not(:last-child):after {
|
495
|
+
border-left-color: var(--emfe-w-color-white, #FFFFFF);
|
496
|
+
}
|
497
|
+
li:focus-within a:first-child:not(:last-child):after {
|
498
|
+
border-left-color: var(--emfe-w-color-white, #FFFFFF);
|
499
|
+
}
|
500
|
+
&> li:hover > a:first-child:not(:last-child):after {
|
501
|
+
border-left-color: transparent;
|
502
|
+
border-top-color: var(--emfe-w-color-white, #FFFFFF);
|
503
|
+
}
|
504
|
+
&> li:focus-within > a:first-child:not(:last-child):after {
|
505
|
+
border-left-color: transparent;
|
506
|
+
border-top-color: var(--emfe-w-color-white, #FFFFFF);
|
507
|
+
}
|
508
|
+
}
|
509
|
+
|
317
510
|
@media only screen and (max-width: 1024px) {
|
318
511
|
.CarouselContainerHeaderMain {
|
319
512
|
.CarouselLeftArrow, .CarouselRightArrow {
|
@@ -321,4 +514,5 @@
|
|
321
514
|
}
|
322
515
|
}
|
323
516
|
}
|
517
|
+
|
324
518
|
</style>
|