@everymatrix/casino-slider 0.0.224 → 0.0.229

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@everymatrix/casino-slider",
3
- "version": "0.0.224",
3
+ "version": "0.0.229",
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": "56c929409f6926e8a96fcfbe5070643a08ae19cd"
39
+ "gitHead": "efee0743817693e5186a61a1477e081208d48fec"
40
40
  }
@@ -4,65 +4,61 @@
4
4
  import { onMount } from 'svelte';
5
5
  import { getDevice } from 'rvhelper';
6
6
 
7
- export let sliderdata:Array<any> = [];
8
- export let onclickeventname:string = 'defaultEvent';
7
+ export let actionevent:string = 'defaultEvent';
9
8
  export let favoritesnumber:string = '0';
10
9
  export let location:string = '';
11
10
  export let clientstyling:string = '';
12
11
  export let clientstylingurl:string = '';
13
12
  export let identity:string = '';
14
13
  export let containermaxwidth:string = '';
14
+ export let activeindex:string = '';
15
15
 
16
- let userAgent:String = window.navigator.userAgent;
17
- let isMobile = (getDevice(userAgent) === 'PC') ? false : true;
16
+ let userAgent:string = window.navigator.userAgent;
17
+ let isMobile:boolean = (getDevice(userAgent) === 'PC') ? false : true;
18
+ let sliderdata:string = '';
18
19
 
19
20
  let carousel:any;
20
- let active:number;
21
+ let activeIndex:number;
21
22
  let customStylingContainer:HTMLElement;
22
23
 
23
24
  // Clicking on the slider item will trigger this method and send a postmessage on window
24
25
  // @TODO itemId type fix
25
- let handleClick = (itemId:any, index:number) => {
26
- active = index;
26
+ let handleClick = (item:any, index:number):void => {
27
+ activeIndex = index;
27
28
 
28
- window.postMessage({ type: onclickeventname, itemId, index }, window.location.href);
29
+ window.postMessage({ type: actionevent, itemId: item.id, index, item }, window.location.href);
29
30
  };
30
31
 
31
- const messageHandler = (e:any) => {
32
- if (e.data && e.data.type == "SetSliderIndex") {
33
- active = e.data.categoryData ? sliderdata.map((e) => { return e.id; }).indexOf(e.data.categoryData.id) : 0;
34
- }
35
-
36
- if (e.data && e.data.type == `SetSliderIndex_${identity}`) {
37
- active = e.data.index;
38
- }
39
- }
40
-
41
- let scrollLeft = () => {
32
+ let scrollLeft = ():void => {
42
33
  carousel.scrollBy({
43
- left: -300,
34
+ left: -250,
44
35
  behavior: 'smooth'
45
36
  });
46
37
  }
47
38
 
48
- let scrollRight = () => {
39
+ let scrollRight = ():void => {
49
40
  carousel.scrollBy({
50
- left: +300,
41
+ left: +250,
51
42
  behavior: 'smooth'
52
43
  });
53
44
  }
54
45
 
55
- const setClientStyling = () => {
46
+ const setActiveIndex = ():void => {
47
+ activeIndex = parseInt(activeindex, 10);
48
+ }
49
+
50
+ const setClientStyling = ():void => {
56
51
  let sheet = document.createElement('style');
57
52
  sheet.innerHTML = clientstyling;
58
53
  setTimeout(() => { customStylingContainer.appendChild(sheet); });
59
54
  }
60
55
 
61
- const setClientStylingURL = () => {
56
+ const setClientStylingURL = ():void => {
62
57
  let cssFile = document.createElement('style');
58
+ let url:URL = new URL(clientstylingurl);
63
59
 
64
60
  if (clientstylingurl) {
65
- fetch(new URL(clientstylingurl))
61
+ fetch(url.href)
66
62
  .then((res:any) => res.text())
67
63
  .then((data:any) => {
68
64
  cssFile.innerHTML = data
@@ -72,14 +68,21 @@
72
68
  }
73
69
  }
74
70
 
71
+ const messageHandler = (e:any) => {
72
+ if (e.data.type == 'SliderData' && e.data.identity == identity) {
73
+ sliderdata = e.data.data;
74
+ }
75
+ }
76
+
75
77
  onMount(() => {
76
78
  window.addEventListener('message', messageHandler, false);
77
79
 
78
80
  return () => {
79
81
  window.removeEventListener('message', messageHandler);
80
82
  }
81
- });
83
+ })
82
84
 
85
+ $: (activeindex || activeindex == 0) && setActiveIndex();
83
86
  $: clientstyling && setClientStyling();
84
87
  $: clientstylingurl && setClientStylingURL();
85
88
  </script>
@@ -95,9 +98,9 @@
95
98
  <ul class="CarouselItems" bind:this={carousel}>
96
99
  {#if sliderdata.length > 0}
97
100
  {#each sliderdata as item, index (item.id)}
98
- <li class="CarouselItem" class:active={active == index} on:click={e => handleClick(item.id, index)}>
101
+ <li class="CarouselItem" class:active={activeIndex == index} on:click={e => handleClick(item, index)}>
99
102
  {#if location === 'headerMain'}
100
- <a href={item.path}>{item.label}</a>
103
+ <a>{item.label}</a>
101
104
  {:else}
102
105
  {item.name} {item.id === "FAVORITES" ? "(" + favoritesnumber + ")" : ''}
103
106
  {/if}
@@ -134,9 +137,9 @@
134
137
  }
135
138
 
136
139
  .CarouselWrapper {
137
- background: #D0046C; /* fallback for old browsers */
138
- background: -webkit-linear-gradient(to left, #FD2839, #D0046C); /* Chrome 10-25, Safari 5.1-6 */
139
- background: linear-gradient(to left, #FD2839, #D0046C); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
140
+ background: var(--emfe-w-color-primary, #D0046C); /* fallback for old browsers */
141
+ background: -webkit-linear-gradient(to left, var(--emfe-w-color-secondary, #FD2839), var(--emfe-w-color-primary, #D0046C)); /* Chrome 10-25, Safari 5.1-6 */
142
+ background: linear-gradient(to left, var(--emfe-w-color-secondary, #FD2839), var(--emfe-w-color-primary, #D0046C)); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
140
143
  &.CarouselWrapperHeaderMain {
141
144
  background: transparent;
142
145
  }
@@ -148,7 +151,7 @@
148
151
  flex-wrap: nowrap;
149
152
  justify-content: center;
150
153
  width: 100%;
151
- color: #ffffff;
154
+ color: var(--emfe-w-color-white, #FFFFFF);
152
155
  margin: 0 auto;
153
156
  padding: 0 10px;
154
157
  &.CarouselContainerMobile {
@@ -182,7 +185,7 @@
182
185
 
183
186
  &:hover,
184
187
  &.active {
185
- background: #07072a;
188
+ background: var(--emfe-w-color-contrast, #07072A);
186
189
  cursor: pointer;
187
190
  }
188
191
  }
@@ -212,8 +215,8 @@
212
215
  &:hover, &.active {
213
216
  background: transparent;
214
217
  a {
215
- border-top: 1px solid #D0046C;
216
- color: #D0046C;
218
+ border-top: 1px solid var(--emfe-w-color-primary, #D0046C);
219
+ color: var(--emfe-w-color-primary, #D0046C);
217
220
  }
218
221
  }
219
222
  span {
@@ -234,7 +237,7 @@
234
237
  display: none;
235
238
  }
236
239
  .CarouselItem a {
237
- color: #fff;
240
+ color: var(--emfe-w-color-white, #FFFFFF);
238
241
  text-decoration: none;
239
242
  }
240
243
  }