@covet-pics/covet-pics-widget 0.162.3 → 0.162.4
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/covet-pics-widget.cjs.entry.js +47 -6
- package/dist/cjs/covet-pics-widget.cjs.entry.js.map +1 -1
- package/dist/cjs/covet-pics-widget.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/covet-pics-widget/covet-pics-widget.css +1 -0
- package/dist/collection/components/covet-pics-widget/covet-pics-widget.js +66 -5
- package/dist/collection/components/covet-pics-widget/covet-pics-widget.js.map +1 -1
- package/dist/covet-pics-widget/covet-pics-widget.esm.js +1 -1
- package/dist/covet-pics-widget/covet-pics-widget.esm.js.map +1 -1
- package/dist/covet-pics-widget/{p-d6f3626d.system.entry.js → p-11e9bee7.system.entry.js} +2 -2
- package/dist/covet-pics-widget/p-11e9bee7.system.entry.js.map +1 -0
- package/dist/covet-pics-widget/p-3ee04256.system.js +2 -2
- package/dist/covet-pics-widget/p-3ee04256.system.js.map +1 -1
- package/dist/covet-pics-widget/{p-ee6b8f67.entry.js → p-c0214d40.entry.js} +2 -2
- package/dist/covet-pics-widget/p-c0214d40.entry.js.map +1 -0
- package/dist/esm/covet-pics-widget.entry.js +47 -6
- package/dist/esm/covet-pics-widget.entry.js.map +1 -1
- package/dist/esm/covet-pics-widget.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm-es5/covet-pics-widget.entry.js +1 -1
- package/dist/esm-es5/covet-pics-widget.entry.js.map +1 -1
- package/dist/esm-es5/covet-pics-widget.js +2 -2
- package/dist/esm-es5/covet-pics-widget.js.map +1 -1
- package/dist/esm-es5/loader.js +2 -2
- package/dist/esm-es5/loader.js.map +1 -1
- package/dist/types/components/covet-pics-widget/covet-pics-widget.d.ts +9 -0
- package/dist/types/components.d.ts +8 -0
- package/package.json +1 -1
- package/dist/covet-pics-widget/p-d6f3626d.system.entry.js.map +0 -1
- package/dist/covet-pics-widget/p-ee6b8f67.entry.js.map +0 -1
|
@@ -956,7 +956,7 @@ function configureStore () {
|
|
|
956
956
|
}
|
|
957
957
|
// export default store;
|
|
958
958
|
|
|
959
|
-
const covetPicsWidgetCss = ":host{--covet-font-family:var(--covet-custom-font-family, var(--covet-internal-font-family)), sans-serif}:host{font-family:var(--covet-font-family);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;display:block}:host .error-message{text-align:center;border:2px dashed;padding:20px}";
|
|
959
|
+
const covetPicsWidgetCss = ":host{--covet-font-family:var(--covet-custom-font-family, var(--covet-internal-font-family)), sans-serif}:host{font-family:var(--covet-font-family);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;display:block;min-height:var(--covet-widget-min-height)}:host .error-message{text-align:center;border:2px dashed;padding:20px}";
|
|
960
960
|
const CovetPicsWidgetStyle0 = covetPicsWidgetCss;
|
|
961
961
|
|
|
962
962
|
const CovetPicsWidget = class {
|
|
@@ -968,6 +968,10 @@ const CovetPicsWidget = class {
|
|
|
968
968
|
* Shows whether widget is embedded to a preview page
|
|
969
969
|
*/
|
|
970
970
|
this.previewMode = false;
|
|
971
|
+
/**
|
|
972
|
+
* Lazy load widget
|
|
973
|
+
*/
|
|
974
|
+
this.lazyLoad = false;
|
|
971
975
|
this.isLoading = true;
|
|
972
976
|
this.items = [];
|
|
973
977
|
this.fetchingError = null;
|
|
@@ -1049,11 +1053,52 @@ const CovetPicsWidget = class {
|
|
|
1049
1053
|
this.loadData();
|
|
1050
1054
|
}
|
|
1051
1055
|
componentWillLoad() {
|
|
1056
|
+
if (this.lazyLoad) {
|
|
1057
|
+
this.setupLazyLoading();
|
|
1058
|
+
}
|
|
1059
|
+
else {
|
|
1060
|
+
this.initApp();
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
setupLazyLoading() {
|
|
1064
|
+
const MIN_HEIGHT_PROPERTY = '--covet-widget-min-height';
|
|
1065
|
+
this.el.style.setProperty(MIN_HEIGHT_PROPERTY, '5px');
|
|
1066
|
+
this.intersectionObserver = this.observeElementVisibility(this.el, () => {
|
|
1067
|
+
this.initApp();
|
|
1068
|
+
this.widgetResizeObserver();
|
|
1069
|
+
this.el.style.setProperty(MIN_HEIGHT_PROPERTY, '0');
|
|
1070
|
+
});
|
|
1071
|
+
}
|
|
1072
|
+
componentDidLoad() {
|
|
1073
|
+
if (!this.lazyLoad) {
|
|
1074
|
+
this.widgetResizeObserver();
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
disconnectedCallback() {
|
|
1078
|
+
this.unsubscribe();
|
|
1079
|
+
if (this.resizeObserver) {
|
|
1080
|
+
this.resizeObserver.disconnect();
|
|
1081
|
+
}
|
|
1082
|
+
if (this.intersectionObserver) {
|
|
1083
|
+
this.intersectionObserver.disconnect();
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
observeElementVisibility(el, callback) {
|
|
1087
|
+
const observer = new IntersectionObserver(entries => {
|
|
1088
|
+
if (entries.length > 0 && entries[0].isIntersecting) {
|
|
1089
|
+
callback();
|
|
1090
|
+
observer.unobserve(el);
|
|
1091
|
+
}
|
|
1092
|
+
});
|
|
1093
|
+
observer.observe(el);
|
|
1094
|
+
return observer;
|
|
1095
|
+
}
|
|
1096
|
+
initApp() {
|
|
1052
1097
|
this.initAppStore();
|
|
1053
1098
|
this.setupLoader();
|
|
1054
1099
|
this.loadData();
|
|
1055
1100
|
}
|
|
1056
|
-
|
|
1101
|
+
widgetResizeObserver() {
|
|
1057
1102
|
this.resizeObserver = new ResizeObserver(() => {
|
|
1058
1103
|
const isWindowHeightChanged = this.appState.size.windowHeight !== window.innerHeight;
|
|
1059
1104
|
if (isWindowHeightChanged) {
|
|
@@ -1069,10 +1114,6 @@ const CovetPicsWidget = class {
|
|
|
1069
1114
|
this.resizeObserver.observe(this.el.parentElement);
|
|
1070
1115
|
}
|
|
1071
1116
|
}
|
|
1072
|
-
disconnectedCallback() {
|
|
1073
|
-
this.unsubscribe();
|
|
1074
|
-
this.resizeObserver.disconnect();
|
|
1075
|
-
}
|
|
1076
1117
|
initAppStore() {
|
|
1077
1118
|
this.appStore = configureStore();
|
|
1078
1119
|
const widgetIdParams = storeUtils.getWidgetId(this.galleryEmbedId, this.shop, this.photoRequestId, this.el);
|