@everymatrix/casino-engagement-suite-container 1.77.0 → 1.77.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/casino-engagement-suite-container/casino-engagement-suite-bar_17.entry.js +1 -1
- package/dist/casino-engagement-suite-container/casino-engagement-suite-container.esm.js +1 -1
- package/dist/casino-engagement-suite-container/ui-image.entry.js +1 -1
- package/dist/cjs/casino-engagement-suite-bar_17.cjs.entry.js +38 -17
- package/dist/cjs/casino-engagement-suite-container.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/ui-image.cjs.entry.js +113 -32
- package/dist/esm/casino-engagement-suite-bar_17.entry.js +38 -17
- package/dist/esm/casino-engagement-suite-container.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/ui-image.entry.js +113 -32
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/casino-engagement-suite-container/.stencil/tools/plugins/index.d.ts +1 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/casino-engagement-suite-container/.stencil/tools/plugins/lazy-load-chunk-plugin.d.ts +12 -0
- package/package.json +1 -1
|
@@ -6,59 +6,140 @@ const UiImageStyle0 = uiImageCss;
|
|
|
6
6
|
const UiImage = class {
|
|
7
7
|
constructor(hostRef) {
|
|
8
8
|
registerInstance(this, hostRef);
|
|
9
|
+
this.hasStarted = false;
|
|
9
10
|
this.src = undefined;
|
|
10
11
|
this.width = undefined;
|
|
11
12
|
this.height = undefined;
|
|
12
13
|
this.alt = undefined;
|
|
13
14
|
this.styles = undefined;
|
|
14
15
|
this.detectDistance = '200px';
|
|
16
|
+
this.loading = 'lazy';
|
|
15
17
|
this.imgLoaded = false;
|
|
16
|
-
this.shouldLoad = false;
|
|
17
18
|
}
|
|
18
|
-
|
|
19
|
-
if (
|
|
19
|
+
onSrcChange() {
|
|
20
|
+
if (this.loading === 'eager')
|
|
20
21
|
return;
|
|
22
|
+
this.imgLoaded = false;
|
|
23
|
+
this.hasStarted = false;
|
|
24
|
+
if (typeof window === 'undefined' || !('IntersectionObserver' in window)) {
|
|
25
|
+
this.beginLoad();
|
|
21
26
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
}
|
|
28
|
+
onLoadingChange(newVal, oldVal) {
|
|
29
|
+
if (newVal === oldVal)
|
|
30
|
+
return;
|
|
31
|
+
this.cleanupObserver();
|
|
32
|
+
this.detachImgHandlers();
|
|
33
|
+
if (newVal === 'eager') {
|
|
34
|
+
if (this.imgEl && this.src) {
|
|
35
|
+
this.imgEl.src = this.src;
|
|
28
36
|
}
|
|
29
|
-
|
|
30
|
-
|
|
37
|
+
this.hasStarted = true;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
this.imgLoaded = false;
|
|
41
|
+
this.hasStarted = false;
|
|
42
|
+
this.setupObserver();
|
|
43
|
+
}
|
|
31
44
|
}
|
|
32
45
|
componentDidLoad() {
|
|
33
|
-
if ('
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
if (this.loading === 'eager')
|
|
47
|
+
return;
|
|
48
|
+
this.setupObserver();
|
|
49
|
+
}
|
|
50
|
+
disconnectedCallback() {
|
|
51
|
+
this.cleanupObserver();
|
|
52
|
+
this.detachImgHandlers();
|
|
53
|
+
}
|
|
54
|
+
canUseIO() {
|
|
55
|
+
return typeof window !== 'undefined' && 'IntersectionObserver' in window;
|
|
56
|
+
}
|
|
57
|
+
setupObserver() {
|
|
58
|
+
if (this.loading === 'eager')
|
|
59
|
+
return;
|
|
60
|
+
if (!this.canUseIO()) {
|
|
61
|
+
this.beginLoad();
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
this.io = new IntersectionObserver((entries) => {
|
|
65
|
+
var _a;
|
|
66
|
+
for (const entry of entries) {
|
|
67
|
+
if (entry.isIntersecting) {
|
|
68
|
+
this.beginLoad();
|
|
69
|
+
(_a = this.io) === null || _a === void 0 ? void 0 : _a.unobserve(entry.target);
|
|
70
|
+
this.cleanupObserver();
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
48
73
|
}
|
|
49
|
-
|
|
74
|
+
}, { root: null, rootMargin: this.detectDistance, threshold: 0 });
|
|
75
|
+
this.io.observe(this.el);
|
|
76
|
+
}
|
|
77
|
+
cleanupObserver() {
|
|
78
|
+
var _a;
|
|
79
|
+
(_a = this.io) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
80
|
+
this.io = undefined;
|
|
81
|
+
}
|
|
82
|
+
wireOnceHandlers() {
|
|
83
|
+
if (!this.imgEl)
|
|
84
|
+
return;
|
|
85
|
+
this.detachImgHandlers();
|
|
86
|
+
this._onLoad = () => {
|
|
87
|
+
var _a;
|
|
88
|
+
if (this.currentSrc && ((_a = this.imgEl) === null || _a === void 0 ? void 0 : _a.currentSrc) && !this.imgEl.currentSrc.includes(this.currentSrc))
|
|
89
|
+
return;
|
|
90
|
+
this.imgLoaded = true;
|
|
91
|
+
};
|
|
92
|
+
this._onError = () => {
|
|
93
|
+
console.error('Load image failed:', this.src);
|
|
94
|
+
};
|
|
95
|
+
this.imgEl.addEventListener('load', this._onLoad, { once: true });
|
|
96
|
+
this.imgEl.addEventListener('error', this._onError, { once: true });
|
|
97
|
+
}
|
|
98
|
+
detachImgHandlers() {
|
|
99
|
+
if (!this.imgEl)
|
|
100
|
+
return;
|
|
101
|
+
if (this._onLoad)
|
|
102
|
+
this.imgEl.removeEventListener('load', this._onLoad);
|
|
103
|
+
if (this._onError)
|
|
104
|
+
this.imgEl.removeEventListener('error', this._onError);
|
|
105
|
+
this._onLoad = undefined;
|
|
106
|
+
this._onError = undefined;
|
|
107
|
+
}
|
|
108
|
+
beginLoad() {
|
|
109
|
+
if (this.hasStarted)
|
|
110
|
+
return;
|
|
111
|
+
if (!this.imgEl)
|
|
112
|
+
return;
|
|
113
|
+
if (!this.src)
|
|
114
|
+
return;
|
|
115
|
+
this.hasStarted = true;
|
|
116
|
+
this.wireOnceHandlers();
|
|
117
|
+
if (this.imgEl.complete && this.imgEl.naturalWidth > 0) {
|
|
118
|
+
this.imgLoaded = true;
|
|
119
|
+
return;
|
|
50
120
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
121
|
+
this.currentSrc = this.src;
|
|
122
|
+
this.imgEl.src = this.src;
|
|
123
|
+
if (this.imgEl.complete && this.imgEl.naturalWidth > 0) {
|
|
124
|
+
this.imgLoaded = true;
|
|
54
125
|
}
|
|
55
126
|
}
|
|
127
|
+
get showSkeleton() {
|
|
128
|
+
return this.loading !== 'eager' && !this.imgLoaded;
|
|
129
|
+
}
|
|
130
|
+
renderEager() {
|
|
131
|
+
return (h(Host, { class: "HostContainer" }, h("img", { src: this.src, decoding: "async", style: this.styles, class: "UiContainer Visible", alt: this.alt, width: this.width, height: this.height, loading: "eager" })));
|
|
132
|
+
}
|
|
133
|
+
renderLazy() {
|
|
134
|
+
return (h(Host, { class: "HostContainer", "aria-busy": !this.imgLoaded ? 'true' : 'false' }, this.showSkeleton && (h("ui-skeleton", { class: "UiContainer", structure: "image", width: "100%", height: "100%" })), h("img", { ref: (el) => (this.imgEl = el), src: undefined, decoding: "async", style: this.styles, class: `UiContainer ${this.imgLoaded ? 'Visible' : 'Hidden'}`, alt: this.alt, width: this.width, height: this.height, loading: "lazy" })));
|
|
135
|
+
}
|
|
56
136
|
render() {
|
|
57
|
-
return
|
|
137
|
+
return this.loading === 'eager' ? this.renderEager() : this.renderLazy();
|
|
58
138
|
}
|
|
59
139
|
get el() { return getElement(this); }
|
|
60
140
|
static get watchers() { return {
|
|
61
|
-
"src": ["
|
|
141
|
+
"src": ["onSrcChange"],
|
|
142
|
+
"loading": ["onLoadingChange"]
|
|
62
143
|
}; }
|
|
63
144
|
};
|
|
64
145
|
UiImage.style = UiImageStyle0;
|