@everymatrix/general-slider-navigation 1.16.1
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/general-slider-navigation.cjs.entry.js +362 -0
- package/dist/cjs/general-slider-navigation.cjs.js +19 -0
- package/dist/cjs/index-3420513e.js +1282 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/loader.cjs.js +21 -0
- package/dist/collection/collection-manifest.json +12 -0
- package/dist/collection/components/general-slider-navigation/general-slider-navigation.css +282 -0
- package/dist/collection/components/general-slider-navigation/general-slider-navigation.js +586 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/utils/locale.utils.js +28 -0
- package/dist/collection/utils/utils.js +56 -0
- package/dist/components/general-slider-navigation.d.ts +11 -0
- package/dist/components/general-slider-navigation.js +398 -0
- package/dist/components/index.d.ts +26 -0
- package/dist/components/index.js +1 -0
- package/dist/esm/general-slider-navigation.entry.js +358 -0
- package/dist/esm/general-slider-navigation.js +17 -0
- package/dist/esm/index-22e4ccbc.js +1256 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/loader.js +17 -0
- package/dist/esm/polyfills/core-js.js +11 -0
- package/dist/esm/polyfills/css-shim.js +1 -0
- package/dist/esm/polyfills/dom.js +79 -0
- package/dist/esm/polyfills/es5-html-element.js +1 -0
- package/dist/esm/polyfills/index.js +34 -0
- package/dist/esm/polyfills/system.js +6 -0
- package/dist/general-slider-navigation/general-slider-navigation.esm.js +1 -0
- package/dist/general-slider-navigation/index.esm.js +0 -0
- package/dist/general-slider-navigation/p-b72fe935.js +1 -0
- package/dist/general-slider-navigation/p-c80bf480.entry.js +1 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/stencil.config.js +22 -0
- package/dist/types/Users/adrian.pripon/Documents/Work/widgets-stencil/packages/general-slider-navigation/.stencil/packages/general-slider-navigation/stencil.config.d.ts +2 -0
- package/dist/types/components/general-slider-navigation/general-slider-navigation.d.ts +100 -0
- package/dist/types/components.d.ts +157 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/stencil-public-runtime.d.ts +1565 -0
- package/dist/types/utils/locale.utils.d.ts +1 -0
- package/dist/types/utils/utils.d.ts +10 -0
- package/loader/cdn.js +3 -0
- package/loader/index.cjs.js +3 -0
- package/loader/index.d.ts +12 -0
- package/loader/index.es2017.js +3 -0
- package/loader/index.js +4 -0
- package/loader/package.json +10 -0
- package/package.json +19 -0
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
|
|
2
|
+
|
|
3
|
+
const DEFAULT_LANGUAGE = 'en';
|
|
4
|
+
const SUPPORTED_LANGUAGES = ['ro', 'en', 'fr', 'ar', 'hu'];
|
|
5
|
+
const TRANSLATIONS = {
|
|
6
|
+
en: {
|
|
7
|
+
error: 'Error',
|
|
8
|
+
noResults: 'Loading, please wait ...',
|
|
9
|
+
},
|
|
10
|
+
hu: {
|
|
11
|
+
error: 'Error',
|
|
12
|
+
noResults: 'Loading, please wait ...',
|
|
13
|
+
},
|
|
14
|
+
ro: {
|
|
15
|
+
error: 'Eroare',
|
|
16
|
+
noResults: 'Loading, please wait ...',
|
|
17
|
+
},
|
|
18
|
+
fr: {
|
|
19
|
+
error: 'Error',
|
|
20
|
+
noResults: 'Loading, please wait ...',
|
|
21
|
+
},
|
|
22
|
+
ar: {
|
|
23
|
+
error: 'خطأ',
|
|
24
|
+
noResults: 'Loading, please wait ...',
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const translate = (key, customLang) => {
|
|
28
|
+
const lang = customLang;
|
|
29
|
+
return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @name isMobile
|
|
34
|
+
* @description A method that returns if the browser used to access the app is from a mobile device or not
|
|
35
|
+
* @param {String} userAgent window.navigator.userAgent
|
|
36
|
+
* @returns {Boolean} true or false
|
|
37
|
+
*/
|
|
38
|
+
const isMobile = (userAgent) => {
|
|
39
|
+
return !!(userAgent.toLowerCase().match(/android/i) ||
|
|
40
|
+
userAgent.toLowerCase().match(/blackberry|bb/i) ||
|
|
41
|
+
userAgent.toLowerCase().match(/iphone|ipad|ipod/i) ||
|
|
42
|
+
userAgent.toLowerCase().match(/windows phone|windows mobile|iemobile|wpdesktop/i));
|
|
43
|
+
};
|
|
44
|
+
const getDevice = () => {
|
|
45
|
+
let userAgent = window.navigator.userAgent;
|
|
46
|
+
if (userAgent.toLowerCase().match(/android/i)) {
|
|
47
|
+
return 'Android';
|
|
48
|
+
}
|
|
49
|
+
if (userAgent.toLowerCase().match(/iphone/i)) {
|
|
50
|
+
return 'iPhone';
|
|
51
|
+
}
|
|
52
|
+
if (userAgent.toLowerCase().match(/ipad|ipod/i)) {
|
|
53
|
+
return 'iPad';
|
|
54
|
+
}
|
|
55
|
+
return 'PC';
|
|
56
|
+
};
|
|
57
|
+
const getDevicePlatform = () => {
|
|
58
|
+
const device = getDevice();
|
|
59
|
+
if (device) {
|
|
60
|
+
if (device === 'PC') {
|
|
61
|
+
return 'dk';
|
|
62
|
+
}
|
|
63
|
+
else if (device === 'iPad' || device === 'iPhone') {
|
|
64
|
+
return 'ios';
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
return 'mtWeb';
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
function checkDeviceType() {
|
|
72
|
+
const userAgent = navigator.userAgent.toLowerCase();
|
|
73
|
+
const width = screen.availWidth;
|
|
74
|
+
const height = screen.availHeight;
|
|
75
|
+
if (userAgent.includes('iphone')) {
|
|
76
|
+
return 'mobile';
|
|
77
|
+
}
|
|
78
|
+
if (userAgent.includes('android')) {
|
|
79
|
+
if (height > width && width < 800) {
|
|
80
|
+
return 'mobile';
|
|
81
|
+
}
|
|
82
|
+
if (width > height && height < 800) {
|
|
83
|
+
return 'tablet';
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return 'desktop';
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const generalSliderNavigationCss = ":host {\n display: block;\n}\n\n.PageError {\n display: flex;\n justify-content: center;\n flex-direction: column;\n}\n.PageError.TitleError {\n color: red;\n}\n\nmain {\n width: 100%;\n overflow: hidden;\n}\n\n.SliderItemsWrapper {\n display: flex;\n flex-direction: row;\n width: 100%;\n}\n\n.SliderWrapperContent {\n display: flex;\n justify-content: center;\n flex-direction: row;\n width: 100%;\n}\n\n.SliderItems {\n display: flex;\n transition: transform 0.4s ease-in-out;\n transform: translateX(0px);\n}\n\n.SliderItem {\n flex: 0 0 auto;\n width: 100%;\n display: flex;\n flex-direction: column;\n justify-content: flex-start;\n align-items: center;\n border-radius: 5px;\n user-select: none;\n}\n\n.GridContainer {\n display: grid;\n grid-template-columns: 1fr;\n grid-template-rows: 1fr 1fr;\n gap: 0px 0px;\n margin: auto;\n width: 220px;\n height: 320px;\n border-radius: 5px;\n margin-bottom: 20px;\n background: var(--emfe-w-color-secondary, #FD2839);\n cursor: pointer;\n}\n.GridContainer .SliderImage {\n grid-area: 1/1/2/2;\n}\n.GridContainer .SliderImage img {\n object-fit: cover;\n height: 320px;\n width: 220px;\n border-radius: 5px;\n}\n.GridContainer .SliderContent {\n grid-area: 1/1/3/2;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-end;\n align-items: baseline;\n gap: 5px;\n margin-left: 20px;\n margin-bottom: 20px;\n}\n.GridContainer .SliderContent .DividerElement {\n background: var(--emfe-w-color-secondary, #FD2839);\n height: 3px;\n width: 60px;\n}\n.GridContainer .SliderContent .Title {\n font-size: 22px;\n font-weight: 400;\n text-transform: uppercase;\n color: var(--emfe-w-color-white, #FFFFFF);\n}\n\n.GridItems {\n display: grid;\n grid-template-columns: 49vw 49vw;\n grid-template-rows: auto auto;\n place-content: unset;\n gap: 2vw;\n margin: 0;\n width: 100vw;\n}\n\n.GridContainerMobile {\n display: grid;\n grid-template-columns: 1fr;\n grid-template-rows: 1fr 1fr;\n gap: 0px 0px;\n margin: auto;\n width: 49vw;\n height: 240px;\n border-radius: 15px;\n background: var(--emfe-w-color-secondary, #FD2839);\n cursor: pointer;\n}\n.GridContainerMobile .SliderImage {\n grid-area: 1/1/2/2;\n}\n.GridContainerMobile .SliderImage img {\n width: 49vw;\n object-fit: cover;\n height: 240px;\n border-radius: 5px;\n}\n.GridContainerMobile .SliderContent {\n grid-area: 1/1/3/2;\n display: flex;\n flex-flow: column;\n justify-content: flex-end;\n align-items: baseline;\n gap: 5px;\n margin-left: 20px;\n margin-bottom: 20px;\n}\n.GridContainerMobile .SliderContent .DividerElement {\n background: var(--emfe-w-color-secondary, #FD2839);\n height: 3px;\n width: 60px;\n}\n.GridContainerMobile .SliderContent .Title {\n font-size: 22px;\n font-weight: 400;\n text-transform: uppercase;\n color: var(--emfe-w-color-white, #FFFFFF);\n}\n\n.GridContainerMobile:nth-last-child(1):nth-child(odd) {\n display: grid;\n gap: 0px 0px;\n margin: auto;\n width: 100vw;\n}\n.GridContainerMobile:nth-last-child(1):nth-child(odd) .SliderImage {\n grid-area: 1/1/2/2;\n}\n.GridContainerMobile:nth-last-child(1):nth-child(odd) .SliderImage img {\n width: 100vw;\n object-fit: cover;\n height: 240px;\n border-radius: 5px;\n}\n\n.SliderNavButton {\n border: 0px;\n width: 45px;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n.SliderNavButton svg {\n width: 40px;\n stroke: var(--emfe-w-color-secondary, #FD2839);\n}\n\n.DisabledArrow svg {\n opacity: 0.2;\n stroke: var(--emfe-w-color-secondary, #FD2839);\n pointer-events: none;\n}\n\n@container (max-width: 475px) {\n .SliderItem {\n display: grid;\n grid-template-columns: repeat(auto-fill, max(250px, 1fr));\n color: var(--emfe-w-color-secondary, #FD2839);\n border-radius: 5px;\n user-select: none;\n }\n\n .GridContainer {\n display: grid;\n grid-template-columns: repeat(auto-fill, max(250px, 1fr));\n gap: 10px;\n margin: auto;\n width: 90%;\n height: 220px;\n border-radius: 5px;\n background: var(--emfe-w-color-secondary, #FD2839);\n cursor: pointer;\n }\n .GridContainer .SliderImage {\n grid-area: 1/1/2/2;\n }\n .GridContainer .SliderImage img {\n object-fit: cover;\n height: 220px;\n width: 100%;\n border-radius: 5px;\n }\n .GridContainer .SliderContent {\n grid-area: 1/1/3/2;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-end;\n align-items: baseline;\n gap: 5px;\n margin-left: 20px;\n margin-bottom: 40px;\n }\n .GridContainer .SliderContent .DividerElement {\n background: var(--emfe-w-color-secondary, #FD2839);\n height: 3px;\n width: 60px;\n }\n .GridContainer .SliderContent .Title {\n font-size: 16px;\n font-weight: 400;\n text-transform: uppercase;\n color: var(--emfe-w-color-white, #FFFFFF);\n }\n\n .GridItems {\n display: grid;\n grid-template-columns: 1fr 1fr;\n grid-template-rows: auto auto auto auto;\n gap: 2cqw;\n width: 100cqw;\n justify-items: stretch;\n }\n\n .GridContainerMobile {\n display: grid;\n grid-template-columns: 1fr 1fr;\n grid-template-rows: 1fr 1fr;\n gap: 0px 0px;\n margin: auto;\n height: 200px;\n border-radius: 15px;\n background: white;\n cursor: pointer;\n }\n .GridContainerMobile .SliderImage {\n grid-area: 1/1/2/2;\n }\n .GridContainerMobile .SliderImage img {\n object-fit: cover;\n height: 200px;\n border-radius: 5px;\n }\n .GridContainerMobile .SliderContent {\n grid-area: 1/1/3/2;\n display: flex;\n flex-flow: column;\n justify-content: flex-end;\n align-items: baseline;\n gap: 5px;\n margin-left: 20px;\n margin-bottom: 20px;\n }\n .GridContainerMobile .SliderContent .DividerElement {\n background: var(--emfe-w-color-secondary, #FD2839);\n height: 3px;\n width: 60px;\n }\n .GridContainerMobile .SliderContent .Title {\n font-size: 22px;\n font-weight: 400;\n text-transform: uppercase;\n color: var(--emfe-w-color-white, #FFFFFF);\n }\n}";
|
|
90
|
+
|
|
91
|
+
const GeneralSliderNavigation$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
92
|
+
constructor() {
|
|
93
|
+
super();
|
|
94
|
+
this.__registerHost();
|
|
95
|
+
this.__attachShadow();
|
|
96
|
+
/**
|
|
97
|
+
* Client custom styling via inline style
|
|
98
|
+
*/
|
|
99
|
+
this.clientStyling = '';
|
|
100
|
+
/**
|
|
101
|
+
* Client custom styling via url
|
|
102
|
+
*/
|
|
103
|
+
this.clientStylingUrl = '';
|
|
104
|
+
/**
|
|
105
|
+
* CMS Endpoint stage
|
|
106
|
+
*/
|
|
107
|
+
this.cmsEnv = 'stage';
|
|
108
|
+
/**
|
|
109
|
+
* Language of the widget
|
|
110
|
+
*/
|
|
111
|
+
this.language = 'en';
|
|
112
|
+
/**
|
|
113
|
+
* User roles
|
|
114
|
+
*/
|
|
115
|
+
this.userRoles = 'everyone';
|
|
116
|
+
/**
|
|
117
|
+
* Show slider navigate arrows
|
|
118
|
+
*/
|
|
119
|
+
this.showSliderArrows = true;
|
|
120
|
+
/**
|
|
121
|
+
* Show slider navigate arrows on mobile
|
|
122
|
+
*/
|
|
123
|
+
this.showSliderArrowsMobile = true;
|
|
124
|
+
/**
|
|
125
|
+
* You will see a fixed grid without a slider when using a mobile device.
|
|
126
|
+
*/
|
|
127
|
+
this.showMobileGrid = false;
|
|
128
|
+
/**
|
|
129
|
+
* Set if you want to have a slider on mobile device.
|
|
130
|
+
*/
|
|
131
|
+
this.showNavigationSliderMobile = true;
|
|
132
|
+
/**
|
|
133
|
+
* Set if you want to have a slider on desktop.
|
|
134
|
+
*/
|
|
135
|
+
this.showNavigationSliderDesktop = true;
|
|
136
|
+
/**
|
|
137
|
+
* Specify the number of items you would like to be displayed on desktop.
|
|
138
|
+
*/
|
|
139
|
+
this.itemsPerPageDesktop = 3;
|
|
140
|
+
/**
|
|
141
|
+
* Specify the number of items you would like to be displayed on mobile devices.
|
|
142
|
+
*/
|
|
143
|
+
this.itemsPerPageMobile = 2;
|
|
144
|
+
this.isLoading = true;
|
|
145
|
+
this.limitStylingAppends = false;
|
|
146
|
+
this.hasErrors = false;
|
|
147
|
+
this.device = '';
|
|
148
|
+
this.activeIndex = 0;
|
|
149
|
+
this.sliderMenuElementWidth = 0;
|
|
150
|
+
this.userAgent = window.navigator.userAgent;
|
|
151
|
+
this.isMobile = isMobile(this.userAgent);
|
|
152
|
+
this.allElementsWidth = 0;
|
|
153
|
+
this.xDown = null;
|
|
154
|
+
this.yDown = null;
|
|
155
|
+
this.resizeHandler = () => {
|
|
156
|
+
this.calculateSliderWidth();
|
|
157
|
+
};
|
|
158
|
+
this.orientationChangeHandler = () => {
|
|
159
|
+
setTimeout(() => {
|
|
160
|
+
this.calculateSliderWidth();
|
|
161
|
+
}, 10);
|
|
162
|
+
};
|
|
163
|
+
this.navigationTo = (url, type, isExternal) => {
|
|
164
|
+
if (isExternal) { // if link is external, inform FE
|
|
165
|
+
window.postMessage({ type: 'ExternalLinkNavigation', externalUrl: url, target: isExternal, linkType: type }, window.location.href);
|
|
166
|
+
}
|
|
167
|
+
else { // if link is internal, inform FE
|
|
168
|
+
window.postMessage({ type: 'LinkNavigation', navUrl: url, target: isExternal }, window.location.href);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
this.setImage = (image) => {
|
|
172
|
+
let source = '';
|
|
173
|
+
this.device = checkDeviceType();
|
|
174
|
+
switch (this.device) {
|
|
175
|
+
case 'mobile':
|
|
176
|
+
source = image.srcMobile;
|
|
177
|
+
break;
|
|
178
|
+
case 'tablet':
|
|
179
|
+
source = image.srcTablet;
|
|
180
|
+
break;
|
|
181
|
+
case 'desktop':
|
|
182
|
+
source = image.srcDesktop;
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
return source;
|
|
186
|
+
};
|
|
187
|
+
this.setClientStyling = () => {
|
|
188
|
+
let sheet = document.createElement('style');
|
|
189
|
+
sheet.innerHTML = this.clientStyling;
|
|
190
|
+
this.stylingContainer.prepend(sheet);
|
|
191
|
+
};
|
|
192
|
+
this.setClientStylingURL = () => {
|
|
193
|
+
let url = new URL(this.clientStylingUrl);
|
|
194
|
+
let cssFile = document.createElement('style');
|
|
195
|
+
fetch(url.href)
|
|
196
|
+
.then((res) => res.text())
|
|
197
|
+
.then((data) => {
|
|
198
|
+
cssFile.innerHTML = data;
|
|
199
|
+
setTimeout(() => { this.stylingContainer.prepend(cssFile); }, 1);
|
|
200
|
+
})
|
|
201
|
+
.catch((err) => {
|
|
202
|
+
console.log('error ', err);
|
|
203
|
+
});
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
watchEndpoint(newValue, oldValue) {
|
|
207
|
+
if (newValue && newValue != oldValue && this.cmsEndpoint) {
|
|
208
|
+
this.getGeneralSliderNavigation().then((GeneralSliderNavigation) => {
|
|
209
|
+
this.sliderData = GeneralSliderNavigation;
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
connectedCallback() {
|
|
214
|
+
window.screen.orientation.addEventListener('change', this.orientationChangeHandler);
|
|
215
|
+
}
|
|
216
|
+
componentWillLoad() {
|
|
217
|
+
if (this.cmsEndpoint && this.language) {
|
|
218
|
+
return this.getGeneralSliderNavigation().then((GeneralSliderNavigation) => {
|
|
219
|
+
this.sliderData = GeneralSliderNavigation;
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
componentDidLoad() {
|
|
224
|
+
window.addEventListener('resize', this.resizeHandler);
|
|
225
|
+
}
|
|
226
|
+
componentDidRender() {
|
|
227
|
+
this.el.addEventListener('touchstart', this.handleTouchStart.bind(this), { passive: true });
|
|
228
|
+
this.el.addEventListener('touchmove', this.handleTouchMove.bind(this), { passive: true });
|
|
229
|
+
// start custom styling area
|
|
230
|
+
if (!this.limitStylingAppends && this.stylingContainer) {
|
|
231
|
+
if (this.clientStyling)
|
|
232
|
+
this.setClientStyling();
|
|
233
|
+
this.limitStylingAppends = true;
|
|
234
|
+
}
|
|
235
|
+
// end custom styling area
|
|
236
|
+
}
|
|
237
|
+
componentDidUpdate() {
|
|
238
|
+
this.calculateSliderWidth();
|
|
239
|
+
}
|
|
240
|
+
disconnectedCallback() {
|
|
241
|
+
this.el.removeEventListener('touchstart', this.handleTouchStart);
|
|
242
|
+
this.el.removeEventListener('touchmove', this.handleTouchMove);
|
|
243
|
+
window.screen.orientation.removeEventListener('change', this.orientationChangeHandler);
|
|
244
|
+
window.removeEventListener('resize', this.resizeHandler);
|
|
245
|
+
}
|
|
246
|
+
getGeneralSliderNavigation() {
|
|
247
|
+
let url = new URL(`${this.cmsEndpoint}/${this.language}/homepage`);
|
|
248
|
+
url.searchParams.append('env', this.cmsEnv);
|
|
249
|
+
url.searchParams.append('userRoles', this.userRoles);
|
|
250
|
+
url.searchParams.append('device', getDevicePlatform());
|
|
251
|
+
return new Promise((resolve, reject) => {
|
|
252
|
+
this.isLoading = true;
|
|
253
|
+
fetch(url.href)
|
|
254
|
+
.then((res) => res.json())
|
|
255
|
+
.then((menuSliderData) => {
|
|
256
|
+
resolve(menuSliderData.banners);
|
|
257
|
+
})
|
|
258
|
+
.catch((err) => {
|
|
259
|
+
console.error(err);
|
|
260
|
+
this.hasErrors = true;
|
|
261
|
+
reject(err);
|
|
262
|
+
}).finally(() => {
|
|
263
|
+
this.isLoading = false;
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
handleTouchStart(evt) {
|
|
268
|
+
const firstTouch = this.getTouches(evt)[0];
|
|
269
|
+
this.xDown = firstTouch.clientX;
|
|
270
|
+
this.yDown = firstTouch.clientY;
|
|
271
|
+
}
|
|
272
|
+
handleTouchMove(evt) {
|
|
273
|
+
if (!this.xDown || !this.yDown)
|
|
274
|
+
return;
|
|
275
|
+
let xUp = evt.touches[0].clientX;
|
|
276
|
+
let yUp = evt.touches[0].clientY;
|
|
277
|
+
let xDiff = this.xDown - xUp;
|
|
278
|
+
let yDiff = this.yDown - yUp;
|
|
279
|
+
if (Math.abs(xDiff) > Math.abs(yDiff)) {
|
|
280
|
+
if (xDiff > 0) {
|
|
281
|
+
this.move(1);
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
this.move(-1);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
this.xDown = null;
|
|
288
|
+
this.yDown = null;
|
|
289
|
+
}
|
|
290
|
+
;
|
|
291
|
+
calculateSliderWidth() {
|
|
292
|
+
if (!this.sliderMenuElement)
|
|
293
|
+
return;
|
|
294
|
+
this.sliderMenuElementWidth = this.sliderMenuElement.clientWidth;
|
|
295
|
+
}
|
|
296
|
+
;
|
|
297
|
+
getTouches(evt) {
|
|
298
|
+
return evt.touches || evt.originalEvent.touches;
|
|
299
|
+
}
|
|
300
|
+
setActive(index) {
|
|
301
|
+
const maxLength = Math.ceil(this.sliderData.length / (!this.isMobile ? this.itemsPerPageDesktop : this.itemsPerPageMobile));
|
|
302
|
+
if (index >= 0) {
|
|
303
|
+
if (index >= maxLength - 1) {
|
|
304
|
+
this.activeIndex = maxLength - 1;
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
this.activeIndex = index;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
else {
|
|
311
|
+
this.activeIndex = 0;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
move(direction) {
|
|
315
|
+
this.setActive(this.activeIndex + direction);
|
|
316
|
+
}
|
|
317
|
+
;
|
|
318
|
+
goTo(index) {
|
|
319
|
+
let diff = this.activeIndex - index;
|
|
320
|
+
if (diff > 0) {
|
|
321
|
+
for (let i = 0; i < diff; i++) {
|
|
322
|
+
this.move(-1);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
else {
|
|
326
|
+
for (let i = 0; i > diff; i--) {
|
|
327
|
+
this.move(1);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
render() {
|
|
332
|
+
const styles = {
|
|
333
|
+
transform: `translate(${(+this.sliderMenuElementWidth * this.activeIndex) * -1}px, 0px)`
|
|
334
|
+
};
|
|
335
|
+
const itemStyleDesktop = {
|
|
336
|
+
width: `${this.sliderMenuElementWidth / Math.ceil(this.itemsPerPageDesktop)}px`
|
|
337
|
+
};
|
|
338
|
+
const itemStyleMobile = {
|
|
339
|
+
width: `${this.sliderMenuElementWidth / this.itemsPerPageMobile}px`
|
|
340
|
+
};
|
|
341
|
+
if (this.hasErrors) {
|
|
342
|
+
return (h("div", { class: "PageError" }, h("div", { class: "TitleError" }, translate('error', this.language))));
|
|
343
|
+
}
|
|
344
|
+
if (!this.isLoading) {
|
|
345
|
+
return (h("div", { ref: el => this.stylingContainer = el }, h("div", { class: "SliderWrapper" }, h("div", { class: "SliderWrapperContent", ref: (el) => this.slider = el }, ((this.showSliderArrows && !this.isMobile) || (this.showSliderArrowsMobile && this.isMobile)) &&
|
|
346
|
+
h("div", { class: this.activeIndex === 0 ? 'SliderNavButton DisabledArrow' : 'SliderNavButton', onClick: () => this.move(-1) }, h("svg", { fill: "none", stroke: "var(--emfe-w-color-secondary, #FD2839)", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg" }, h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", d: "M15 19l-7-7 7-7" }))), this.showNavigationSliderMobile && this.isMobile ? (h("main", null, h("div", { style: styles, ref: (el) => this.sliderMenuElement = el, class: "SliderItems" }, this.sliderData.map((data) => h("div", { class: "SliderItem", style: itemStyleMobile }, h("div", { class: "GridContainer", onClick: () => data.externalLink ? this.navigationTo(data.url, data.targetType, data.externalLink) : this.navigationTo(data.url, data.targetType, false) }, h("div", { class: "SliderImage" }, h("img", { src: this.setImage(data.image), alt: data.title })), h("div", { class: "SliderContent" }, h("div", { class: "DividerElement" }), h("div", { class: "Title" }, data.title)))))))) : (this.showNavigationSliderDesktop && !this.isMobile &&
|
|
347
|
+
h("main", null, h("div", { class: "SliderItems", style: styles, ref: (el) => this.sliderMenuElement = el }, h("div", { class: "SliderItemsWrapper" }, this.sliderData.map((data) => h("div", { class: "SliderItem", style: itemStyleDesktop }, h("div", { class: "GridContainer", onClick: () => data.externalLink ? this.navigationTo(data.url, data.targetType, data.externalLink) : this.navigationTo(data.url, data.targetType, false) }, h("div", { class: "SliderImage" }, h("img", { src: this.setImage(data.image), alt: data.title })), h("div", { class: "SliderContent" }, h("div", { class: "DividerElement" }), h("div", { class: "Title" }, data.title))))))))), ((this.showSliderArrows && !this.isMobile) || (this.showSliderArrowsMobile && this.isMobile)) &&
|
|
348
|
+
h("div", { class: this.activeIndex === Math.ceil(this.sliderData.length / (!this.isMobile ? this.itemsPerPageDesktop : this.itemsPerPageMobile)) - 1 ? ' SliderNavButton DisabledArrow disabled' : 'SliderNavButton', onClick: () => this.move(1) }, h("svg", { fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg" }, h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", d: "M9 5l7 7-7 7" }))))), (this.showMobileGrid && this.isMobile) &&
|
|
349
|
+
h("main", { class: "GridItems GridMobile" }, this.sliderData.map((dataMobile) => h("div", { class: "GridContainerMobile", onClick: () => dataMobile.externalLink ? this.navigationTo(dataMobile.url, dataMobile.targetType, dataMobile.externalLink) : this.navigationTo(dataMobile.url, dataMobile.targetType, false) }, h("div", { class: "SliderImage" }, h("img", { src: this.setImage(dataMobile.image), alt: dataMobile.title })), h("div", { class: "SliderContent" }, h("div", { class: "DividerElement" }), h("div", { class: "Title" }, dataMobile.title)))))));
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
get el() { return this; }
|
|
353
|
+
static get watchers() { return {
|
|
354
|
+
"cmsEndpoint": ["watchEndpoint"],
|
|
355
|
+
"language": ["watchEndpoint"]
|
|
356
|
+
}; }
|
|
357
|
+
static get style() { return generalSliderNavigationCss; }
|
|
358
|
+
}, [1, "general-slider-navigation", {
|
|
359
|
+
"clientStyling": [513, "client-styling"],
|
|
360
|
+
"clientStylingUrl": [513, "client-styling-url"],
|
|
361
|
+
"cmsEndpoint": [513, "cms-endpoint"],
|
|
362
|
+
"cmsEnv": [513, "cms-env"],
|
|
363
|
+
"language": [513],
|
|
364
|
+
"userRoles": [513, "user-roles"],
|
|
365
|
+
"showSliderArrows": [516, "show-slider-arrows"],
|
|
366
|
+
"showSliderArrowsMobile": [516, "show-slider-arrows-mobile"],
|
|
367
|
+
"showMobileGrid": [516, "show-mobile-grid"],
|
|
368
|
+
"showNavigationSliderMobile": [516, "show-navigation-slider-mobile"],
|
|
369
|
+
"showNavigationSliderDesktop": [516, "show-navigation-slider-desktop"],
|
|
370
|
+
"itemsPerPageDesktop": [514, "items-per-page-desktop"],
|
|
371
|
+
"itemsPerPageMobile": [514, "items-per-page-mobile"],
|
|
372
|
+
"externalLinkActive": [1540, "external-link-active"],
|
|
373
|
+
"internalLinkActive": [1540, "internal-link-active"],
|
|
374
|
+
"isLoading": [32],
|
|
375
|
+
"limitStylingAppends": [32],
|
|
376
|
+
"hasErrors": [32],
|
|
377
|
+
"device": [32],
|
|
378
|
+
"activeIndex": [32],
|
|
379
|
+
"sliderMenuElementWidth": [32]
|
|
380
|
+
}]);
|
|
381
|
+
function defineCustomElement$1() {
|
|
382
|
+
if (typeof customElements === "undefined") {
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
const components = ["general-slider-navigation"];
|
|
386
|
+
components.forEach(tagName => { switch (tagName) {
|
|
387
|
+
case "general-slider-navigation":
|
|
388
|
+
if (!customElements.get(tagName)) {
|
|
389
|
+
customElements.define(tagName, GeneralSliderNavigation$1);
|
|
390
|
+
}
|
|
391
|
+
break;
|
|
392
|
+
} });
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
const GeneralSliderNavigation = GeneralSliderNavigation$1;
|
|
396
|
+
const defineCustomElement = defineCustomElement$1;
|
|
397
|
+
|
|
398
|
+
export { GeneralSliderNavigation, defineCustomElement };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/* GeneralSliderNavigation custom elements */
|
|
2
|
+
|
|
3
|
+
import type { Components, JSX } from "../types/components";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Used to manually set the base path where assets can be found.
|
|
7
|
+
* If the script is used as "module", it's recommended to use "import.meta.url",
|
|
8
|
+
* such as "setAssetPath(import.meta.url)". Other options include
|
|
9
|
+
* "setAssetPath(document.currentScript.src)", or using a bundler's replace plugin to
|
|
10
|
+
* dynamically set the path at build time, such as "setAssetPath(process.env.ASSET_PATH)".
|
|
11
|
+
* But do note that this configuration depends on how your script is bundled, or lack of
|
|
12
|
+
* bundling, and where your assets can be loaded from. Additionally custom bundling
|
|
13
|
+
* will have to ensure the static assets are copied to its build directory.
|
|
14
|
+
*/
|
|
15
|
+
export declare const setAssetPath: (path: string) => void;
|
|
16
|
+
|
|
17
|
+
export interface SetPlatformOptions {
|
|
18
|
+
raf?: (c: FrameRequestCallback) => number;
|
|
19
|
+
ael?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
|
|
20
|
+
rel?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
|
|
21
|
+
}
|
|
22
|
+
export declare const setPlatformOptions: (opts: SetPlatformOptions) => void;
|
|
23
|
+
|
|
24
|
+
export type { Components, JSX };
|
|
25
|
+
|
|
26
|
+
export * from '../types';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { setAssetPath, setPlatformOptions } from '@stencil/core/internal/client';
|