@salla.sa/twilight-components 2.14.351 → 2.14.353
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/{filepond-DmgB2usw.js → filepond-7SxqaoXb.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-poster-Qz9yBcC6.js → filepond-plugin-file-poster-DwIv84hN.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-validate-size-BpxufYGC.js → filepond-plugin-file-validate-size-NUNnIo4Q.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-validate-type-DPpMnDuU.js → filepond-plugin-file-validate-type-CXI-hfww.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-edit-DSig_Hnr.js → filepond-plugin-image-edit-fBeBGIBb.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-exif-orientation-BdyyWkN_.js → filepond-plugin-image-exif-orientation-BmLTdQ6d.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-preview-ClN5AjHL.js → filepond-plugin-image-preview-CssKRM6n.js} +1 -1
- package/dist/cjs/{index-wroCOFea.js → index-B5soIVRX.js} +2 -2
- package/dist/cjs/{index-ByiRU---.js → index-B9TEdQDE.js} +1 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/salla-accordion_62.cjs.entry.js +84 -34
- package/dist/cjs/salla-advertisement.cjs.entry.js +1 -1
- package/dist/cjs/salla-app-install-alert.cjs.entry.js +8 -3
- package/dist/cjs/salla-apps-icons.cjs.entry.js +1 -1
- package/dist/cjs/salla-cart-item-offers.cjs.entry.js +1 -1
- package/dist/cjs/salla-conditional-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-contacts.cjs.entry.js +1 -1
- package/dist/cjs/salla-custom-fields.cjs.entry.js +1 -1
- package/dist/cjs/salla-filters-widget.cjs.entry.js +1 -1
- package/dist/cjs/salla-filters.cjs.entry.js +1 -1
- package/dist/cjs/salla-hook.cjs.entry.js +1 -1
- package/dist/cjs/salla-installment.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-program.cjs.entry.js +1 -1
- package/dist/cjs/salla-metadata.cjs.entry.js +1 -1
- package/dist/cjs/salla-notification-item.cjs.entry.js +1 -1
- package/dist/cjs/salla-notifications.cjs.entry.js +1 -1
- package/dist/cjs/salla-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details-multiple-bundle-product.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details-options.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-summary.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-totals-card.cjs.entry.js +1 -1
- package/dist/cjs/salla-orders.cjs.entry.js +1 -1
- package/dist/cjs/salla-payments.cjs.entry.js +1 -1
- package/dist/cjs/salla-price-range.cjs.entry.js +1 -1
- package/dist/cjs/salla-review-card.cjs.entry.js +1 -1
- package/dist/cjs/salla-reviews-page.cjs.entry.js +1 -1
- package/dist/cjs/salla-reviews.cjs.entry.js +1 -1
- package/dist/cjs/salla-social.cjs.entry.js +1 -1
- package/dist/cjs/salla-tiered-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-tooltip.cjs.entry.js +1 -1
- package/dist/cjs/salla-trust-badges.cjs.entry.js +1 -1
- package/dist/cjs/salla-verify.cjs.entry.js +1 -1
- package/dist/cjs/salla-wallet.cjs.entry.js +1 -1
- package/dist/cjs/twilight.cjs.js +2 -2
- package/dist/cjs/{vanilla-picker-Dud2hHSp.js → vanilla-picker-C6fk8_TR.js} +1 -1
- package/dist/collection/components/salla-add-product-button/salla-add-product-button.js +18 -6
- package/dist/collection/components/salla-app-install-alert/salla-app-install-alert.js +7 -2
- package/dist/collection/components/salla-color-picker/salla-color-picker.js +39 -8
- package/dist/collection/components/salla-maintenance-alert/salla-maintenance-alert.js +4 -2
- package/dist/collection/components/salla-products-list/salla-products-list.js +17 -11
- package/dist/components/index.js +2 -2
- package/dist/components/salla-add-product-button2.js +18 -6
- package/dist/components/salla-app-install-alert.js +7 -2
- package/dist/components/salla-color-picker2.js +38 -7
- package/dist/components/salla-maintenance-alert.js +4 -2
- package/dist/components/salla-products-list2.js +17 -11
- package/dist/esm/{filepond-BcVCWOQQ.js → filepond-Cuqyleyy.js} +1 -1
- package/dist/esm/{filepond-plugin-file-poster-B6OLqzjJ.js → filepond-plugin-file-poster-C6Wara8q.js} +1 -1
- package/dist/esm/{filepond-plugin-file-validate-size-BCifsMdp.js → filepond-plugin-file-validate-size-D-M3KSxo.js} +1 -1
- package/dist/esm/{filepond-plugin-file-validate-type-BzRNZ2wk.js → filepond-plugin-file-validate-type-DzAl1VI8.js} +1 -1
- package/dist/esm/{filepond-plugin-image-edit-Dvu8RWud.js → filepond-plugin-image-edit-flutfc9I.js} +1 -1
- package/dist/esm/{filepond-plugin-image-exif-orientation-DtlS_Id7.js → filepond-plugin-image-exif-orientation-B2UkG6iE.js} +1 -1
- package/dist/esm/{filepond-plugin-image-preview-DRaZsLxF.js → filepond-plugin-image-preview-B4u8N2nE.js} +1 -1
- package/dist/esm/{index-D8IUoDXw.js → index-6mr785rH.js} +2 -2
- package/dist/esm/{index-BT5aIJiI.js → index-xWIb6INF.js} +1 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm/salla-accordion_62.entry.js +84 -34
- package/dist/esm/salla-advertisement.entry.js +1 -1
- package/dist/esm/salla-app-install-alert.entry.js +8 -3
- package/dist/esm/salla-apps-icons.entry.js +1 -1
- package/dist/esm/salla-cart-item-offers.entry.js +1 -1
- package/dist/esm/salla-conditional-offer.entry.js +1 -1
- package/dist/esm/salla-contacts.entry.js +1 -1
- package/dist/esm/salla-custom-fields.entry.js +1 -1
- package/dist/esm/salla-filters-widget.entry.js +1 -1
- package/dist/esm/salla-filters.entry.js +1 -1
- package/dist/esm/salla-hook.entry.js +1 -1
- package/dist/esm/salla-installment.entry.js +1 -1
- package/dist/esm/salla-loyalty-prize-item.entry.js +1 -1
- package/dist/esm/salla-loyalty-program.entry.js +1 -1
- package/dist/esm/salla-metadata.entry.js +1 -1
- package/dist/esm/salla-notification-item.entry.js +1 -1
- package/dist/esm/salla-notifications.entry.js +1 -1
- package/dist/esm/salla-offer.entry.js +1 -1
- package/dist/esm/salla-order-details-multiple-bundle-product.entry.js +1 -1
- package/dist/esm/salla-order-details-options.entry.js +1 -1
- package/dist/esm/salla-order-details.entry.js +1 -1
- package/dist/esm/salla-order-summary.entry.js +1 -1
- package/dist/esm/salla-order-totals-card.entry.js +1 -1
- package/dist/esm/salla-orders.entry.js +1 -1
- package/dist/esm/salla-payments.entry.js +1 -1
- package/dist/esm/salla-price-range.entry.js +1 -1
- package/dist/esm/salla-review-card.entry.js +1 -1
- package/dist/esm/salla-reviews-page.entry.js +1 -1
- package/dist/esm/salla-reviews.entry.js +1 -1
- package/dist/esm/salla-social.entry.js +1 -1
- package/dist/esm/salla-tiered-offer.entry.js +1 -1
- package/dist/esm/salla-tooltip.entry.js +1 -1
- package/dist/esm/salla-trust-badges.entry.js +1 -1
- package/dist/esm/salla-verify.entry.js +1 -1
- package/dist/esm/salla-wallet.entry.js +1 -1
- package/dist/esm/twilight.js +3 -3
- package/dist/esm/{vanilla-picker-BPR2c_5J.js → vanilla-picker-B4PKRAhm.js} +1 -1
- package/dist/twilight/{p-de74f566.entry.js → p-0c87ef6c.entry.js} +1 -1
- package/dist/twilight/{p-9dc0d7cb.entry.js → p-12e49031.entry.js} +1 -1
- package/dist/twilight/{p-403fc5a0.entry.js → p-16b8d78c.entry.js} +1 -1
- package/dist/twilight/{p-1d6ae0cd.entry.js → p-18ebec2c.entry.js} +1 -1
- package/dist/twilight/{p-53bbd4e8.entry.js → p-19e07b9e.entry.js} +1 -1
- package/dist/twilight/{p-ef9334ed.entry.js → p-28900b2e.entry.js} +1 -1
- package/dist/twilight/{p-5a27fc24.entry.js → p-2a26c1d6.entry.js} +1 -1
- package/dist/twilight/{p-46095c81.entry.js → p-2d209f96.entry.js} +1 -1
- package/dist/twilight/{p-fad69d7b.entry.js → p-300624bb.entry.js} +1 -1
- package/dist/twilight/{p-234d4270.entry.js → p-33ea3141.entry.js} +1 -1
- package/dist/twilight/{p-4a269d95.entry.js → p-4253fc44.entry.js} +1 -1
- package/dist/twilight/{p-c8f83a29.entry.js → p-4bc98557.entry.js} +1 -1
- package/dist/twilight/{p-ffcfb224.entry.js → p-5067322a.entry.js} +1 -1
- package/dist/twilight/{p-d8c30c7b.entry.js → p-5bf05092.entry.js} +1 -1
- package/dist/twilight/{p-44c225e2.entry.js → p-6472200c.entry.js} +1 -1
- package/dist/twilight/p-67830f2a.entry.js +4 -0
- package/dist/twilight/{p-8d0e34f8.entry.js → p-6f576591.entry.js} +1 -1
- package/dist/twilight/{p-a50658ad.entry.js → p-6f5d02c6.entry.js} +1 -1
- package/dist/twilight/{p-D8IUoDXw.js → p-6mr785rH.js} +1 -1
- package/dist/twilight/{p-993dff37.entry.js → p-751dddd4.entry.js} +1 -1
- package/dist/twilight/{p-eb109f9d.entry.js → p-7e39343d.entry.js} +1 -1
- package/dist/twilight/{p-8af29c6e.entry.js → p-81702ecb.entry.js} +1 -1
- package/dist/twilight/{p-9a6195f6.entry.js → p-8b018d82.entry.js} +1 -1
- package/dist/twilight/{p-faa4c75d.entry.js → p-8c7b7712.entry.js} +1 -1
- package/dist/twilight/{p-0fb07494.entry.js → p-9946fa76.entry.js} +1 -1
- package/dist/twilight/{p-9ab1a8dd.entry.js → p-9b22a7eb.entry.js} +1 -1
- package/dist/twilight/{p-R8UuPKQS.js → p-B2SkkGH8.js} +1 -1
- package/dist/twilight/{p-mIk_7HE4.js → p-BijadG7g.js} +1 -1
- package/dist/twilight/{p-CLCMzFCR.js → p-Bp_xKTyn.js} +1 -1
- package/dist/twilight/{p-DNuuIRPk.js → p-C_h1JDCU.js} +1 -1
- package/dist/twilight/{p-DhPpUonS.js → p-ChfiVIJv.js} +1 -1
- package/dist/twilight/{p-BjevMNf5.js → p-Cuxsz9f-.js} +1 -1
- package/dist/twilight/{p-DMvcLQlj.js → p-DnELO4MH.js} +1 -1
- package/dist/twilight/{p-5e83dab1.entry.js → p-a515a8cc.entry.js} +1 -1
- package/dist/twilight/{p-6961de25.entry.js → p-ac6fc286.entry.js} +1 -1
- package/dist/twilight/{p-88aa8e1c.entry.js → p-b60db6c8.entry.js} +1 -1
- package/dist/twilight/{p-a0fb9e8d.entry.js → p-c096e336.entry.js} +1 -1
- package/dist/twilight/{p-97d6ac02.entry.js → p-c4821f8b.entry.js} +1 -1
- package/dist/twilight/{p-c5dc7685.entry.js → p-d4aaeef4.entry.js} +1 -1
- package/dist/twilight/{p-cef109da.entry.js → p-dde21f4b.entry.js} +1 -1
- package/dist/twilight/{p-b4bb7b69.entry.js → p-de807340.entry.js} +1 -1
- package/dist/twilight/{p-af71190f.entry.js → p-e909d28b.entry.js} +1 -1
- package/dist/twilight/{p-2986242d.entry.js → p-fa585081.entry.js} +1 -1
- package/dist/twilight/{p-VHxFG8vR.js → p-tFBCbVoG.js} +1 -1
- package/dist/twilight/{p-B1PME38e.js → p-zHj-W7EE.js} +1 -1
- package/dist/twilight/twilight.esm.js +1 -1
- package/dist/types/components/salla-add-product-button/salla-add-product-button.d.ts +5 -0
- package/dist/types/components/salla-app-install-alert/salla-app-install-alert.d.ts +3 -1
- package/dist/types/components/salla-color-picker/salla-color-picker.d.ts +10 -0
- package/dist/types/components/salla-products-list/salla-products-list.d.ts +2 -0
- package/package.json +5 -5
- package/dist/twilight/p-319d0ee6.entry.js +0 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import { h, Host } from "@stencil/core";
|
|
4
|
+
import { h, Host, } from "@stencil/core";
|
|
5
5
|
import ArrowDown from "../../assets/svg/keyboard_arrow_down.svg";
|
|
6
6
|
export class SallaColorPicker {
|
|
7
7
|
constructor() {
|
|
@@ -33,6 +33,10 @@ export class SallaColorPicker {
|
|
|
33
33
|
* Whether to enable adjusting the alpha channel.
|
|
34
34
|
*/
|
|
35
35
|
this.enableAlpha = false;
|
|
36
|
+
this.updateViewportCache = () => {
|
|
37
|
+
this.cachedViewportWidth = this.getViewportWidthFromBreakpoints();
|
|
38
|
+
};
|
|
39
|
+
this.cachedViewportWidth = 0; // Will be populated in componentDidLoad via requestAnimationFrame
|
|
36
40
|
}
|
|
37
41
|
colorChangeHandler(color) {
|
|
38
42
|
if (this.colorInput)
|
|
@@ -50,7 +54,10 @@ export class SallaColorPicker {
|
|
|
50
54
|
this.submitted.emit(color);
|
|
51
55
|
}
|
|
52
56
|
popupOpenedHandler(color) {
|
|
53
|
-
|
|
57
|
+
// Double rAF: defer setPopInPosition (getBoundingClientRect) until after paint to avoid forced reflow
|
|
58
|
+
requestAnimationFrame(() => {
|
|
59
|
+
requestAnimationFrame(() => this.setPopInPosition());
|
|
60
|
+
});
|
|
54
61
|
this.popupOpened.emit(color);
|
|
55
62
|
}
|
|
56
63
|
popupClosedHandler(color) {
|
|
@@ -123,26 +130,47 @@ export class SallaColorPicker {
|
|
|
123
130
|
this.picker = null;
|
|
124
131
|
this.pickerReady = null;
|
|
125
132
|
}
|
|
133
|
+
disconnectedCallback() {
|
|
134
|
+
window.removeEventListener('resize', this.updateViewportCache);
|
|
135
|
+
}
|
|
126
136
|
componentWillLoad() {
|
|
127
137
|
salla.onReady(() => {
|
|
128
138
|
this.color = this.color ? this.color : salla.config.get('theme.color.primary', '#5dd5c4');
|
|
129
139
|
});
|
|
130
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* Returns viewport width from matchMedia breakpoints (no layout read).
|
|
143
|
+
* Must match updateViewportCache breakpoints for consistency.
|
|
144
|
+
*/
|
|
145
|
+
getViewportWidthFromBreakpoints() {
|
|
146
|
+
if (typeof window === 'undefined')
|
|
147
|
+
return 1024;
|
|
148
|
+
if (window.matchMedia('(min-width: 1200px)').matches)
|
|
149
|
+
return 1200;
|
|
150
|
+
if (window.matchMedia('(min-width: 992px)').matches)
|
|
151
|
+
return 992;
|
|
152
|
+
if (window.matchMedia('(min-width: 768px)').matches)
|
|
153
|
+
return 768;
|
|
154
|
+
return 375;
|
|
155
|
+
}
|
|
131
156
|
setPopInPosition() {
|
|
157
|
+
// Use cached viewport width – reading innerWidth at popup open causes forced reflow.
|
|
158
|
+
// Fallback: matchMedia-based value when cache is 0 (e.g. SSR before hydration). Same breakpoints as updateViewportCache.
|
|
159
|
+
const viewportWidth = this.cachedViewportWidth || this.getViewportWidthFromBreakpoints();
|
|
132
160
|
const popup = this.host.querySelector('.picker_wrapper');
|
|
133
161
|
const widgetEl = this.host.querySelector('.s-color-picker-widget');
|
|
134
162
|
if (!popup || !widgetEl)
|
|
135
163
|
return;
|
|
136
164
|
const widgetPosition = widgetEl.getBoundingClientRect();
|
|
137
|
-
const widgetToWindowEq =
|
|
165
|
+
const widgetToWindowEq = viewportWidth / 2 - widgetPosition.width / 2;
|
|
138
166
|
const widgetInLeft = widgetToWindowEq > widgetPosition.x;
|
|
139
167
|
const widgetInRight = widgetToWindowEq < widgetPosition.x;
|
|
140
168
|
const widgetInCenter = widgetToWindowEq === widgetPosition.x;
|
|
141
|
-
const isMobile = window.
|
|
169
|
+
const isMobile = !window.matchMedia('(min-width: 768px)').matches;
|
|
142
170
|
if (isMobile && widgetInLeft) {
|
|
143
171
|
popup.style.left = '0';
|
|
144
172
|
}
|
|
145
|
-
if (isMobile &&
|
|
173
|
+
if (isMobile && widgetInRight) {
|
|
146
174
|
popup.style.left = 'auto';
|
|
147
175
|
}
|
|
148
176
|
if (!isMobile || (isMobile && ((!widgetInRight && !widgetInLeft) || widgetInCenter))) {
|
|
@@ -150,7 +178,7 @@ export class SallaColorPicker {
|
|
|
150
178
|
}
|
|
151
179
|
}
|
|
152
180
|
initColorPicker() {
|
|
153
|
-
this.pickerReady = import('vanilla-picker').then(
|
|
181
|
+
this.pickerReady = import('vanilla-picker').then(mod => {
|
|
154
182
|
const Picker = mod.default;
|
|
155
183
|
const picker = new Picker({
|
|
156
184
|
parent: this.host,
|
|
@@ -170,14 +198,17 @@ export class SallaColorPicker {
|
|
|
170
198
|
});
|
|
171
199
|
}
|
|
172
200
|
render() {
|
|
173
|
-
return (h(Host, { key: '
|
|
201
|
+
return (h(Host, { key: 'dc90f101197031b0ec17939dc940b527cbb42764', class: "s-color-picker-main" }, h("slot", { key: '504a93f8bba3130a953dbfc1e03420d622247c0f', name: "widget" }, h("div", { key: '7eb60d1353d1fa6edefc400d7851499d083c3000', class: "s-color-picker-widget" }, h("div", { key: '01361959e0beeecd5c4b9ba0210931f3864b9273', class: "s-color-picker-widget-canvas", ref: dv => (this.canvas = dv) }), h("span", { key: '4091ba421758a3af182e7224ffbd74c5ca58166a', innerHTML: ArrowDown }))), h("input", { key: '5302b4da7dc9beaec6ab469175dee79d5b8c5dc5', class: "s-hidden", name: this.name, required: this.required, value: this.color, ref: color => (this.colorInput = color) })));
|
|
174
202
|
}
|
|
175
203
|
componentDidLoad() {
|
|
176
204
|
if (this.canvas)
|
|
177
205
|
this.canvas.style.backgroundColor = this.color;
|
|
178
206
|
this.initColorPicker();
|
|
207
|
+
// Populate viewport cache in next frame (avoids forced reflow during initial render)
|
|
208
|
+
requestAnimationFrame(() => this.updateViewportCache());
|
|
209
|
+
window.addEventListener('resize', this.updateViewportCache);
|
|
179
210
|
if (this.colorInput) {
|
|
180
|
-
this.colorInput.addEventListener('invalid',
|
|
211
|
+
this.colorInput.addEventListener('invalid', e => {
|
|
181
212
|
this.invalidInput.emit(e);
|
|
182
213
|
});
|
|
183
214
|
this.colorInput.addEventListener('input', () => {
|
|
@@ -7,14 +7,16 @@ export class SallaMaintenanceAlert {
|
|
|
7
7
|
componentWillLoad() {
|
|
8
8
|
this.title = salla.config.get('maintenance_details.title');
|
|
9
9
|
this.message = salla.config.get('maintenance_details.message');
|
|
10
|
-
|
|
10
|
+
// Use matchMedia instead of window.innerWidth to avoid forced reflow (Lighthouse/PageSpeed)
|
|
11
|
+
const isMobile = typeof window !== 'undefined' && !window.matchMedia('(min-width: 768px)').matches;
|
|
12
|
+
this.buttonTitle = isMobile ? salla.config.get('maintenance_details.button_title') : salla.config.get('maintenance_details.button_full_title');
|
|
11
13
|
}
|
|
12
14
|
closeAlert() {
|
|
13
15
|
salla.storage.set('hide_salla-maintenance-alert_at', Date.now());
|
|
14
16
|
this.host.style.display = 'none';
|
|
15
17
|
}
|
|
16
18
|
render() {
|
|
17
|
-
return (h(Host, { key: '
|
|
19
|
+
return (h(Host, { key: '109e687d7d6ba48ddf89cd3631f5a852d50688fd', class: "s-maintenance-alert-wrapper" }, h("button", { key: 'd70e7e53acc699336e1611589ca3bdfc704504c2', class: "s-maintenance-alert-close", innerHTML: Cancel, onClick: () => this.closeAlert() }), h("div", { key: 'b816c1a9635828c206c792d68203ccfbe8e8235b', class: "s-maintenance-alert-content" }, h("div", { key: '61e91088a5613d943b6f662f5ed44093ecf99237', class: "s-maintenance-alert-container" }, h("div", { key: '1ca223334f52bc5097677dd23433107080567894', class: "s-maintenance-alert-icon" }, h("img", { key: '22e07c7a104267cda2bed74929307d039018698d', src: salla.url.cdn('images/alert.png'), alt: "Alert" })), h("div", { key: '64d37700bc1454f5afadb55b49512bbd5b412d9c', class: "s-maintenance-alert-text" }, h("h2", { key: '7651dcd09a0ba07f14ed744758598015d4b45ecd' }, this.title), h("p", { key: '1f8d057af072466f34d0f3a13396de5144bc967f' }, this.message))), h("div", { key: '34f8471b855011b499c2038b1ac9dd24cc5e2e8b' }, h("a", { key: 'd9c4f4a9fb80ab90c13dc1dde69adcb7c4cd7e9f', class: "s-maintenance-alert-btn", href: salla.config.get('maintenance_details.button_url') }, this.buttonTitle)))));
|
|
18
20
|
}
|
|
19
21
|
componentDidLoad() {
|
|
20
22
|
//auto-hide the alert if close button is clicked before one hour
|
|
@@ -34,6 +34,8 @@ export class SallaProductsList {
|
|
|
34
34
|
this.prevCategoryIdKey = "prevCategoryId";
|
|
35
35
|
this.isProcessing = false; // Tracks if we are processing data
|
|
36
36
|
this.scrollTimeout = null;
|
|
37
|
+
this.boundScrollToLastViewedProduct = () => this.scrollToLastViewedProduct();
|
|
38
|
+
this.boundHandleScroll = () => this.handleScroll();
|
|
37
39
|
this.specialPagesWithoutIds = {
|
|
38
40
|
'product.index.latest': 'latest',
|
|
39
41
|
'product.index.offers': 'offers',
|
|
@@ -58,11 +60,12 @@ export class SallaProductsList {
|
|
|
58
60
|
if ("scrollRestoration" in history)
|
|
59
61
|
history.scrollRestoration = "manual";
|
|
60
62
|
// required for scroll restoration case when the component loads before DOM content is completed (slow internet bandwidth /low device specs)
|
|
61
|
-
window.addEventListener('DOMContentLoaded', this.
|
|
63
|
+
window.addEventListener('DOMContentLoaded', this.boundScrollToLastViewedProduct);
|
|
62
64
|
salla.event.on('salla-filters::changed', filters => this.setFilters(filters));
|
|
63
65
|
}
|
|
64
66
|
disconnectedCallback() {
|
|
65
|
-
window.removeEventListener('DOMContentLoaded', this.
|
|
67
|
+
window.removeEventListener('DOMContentLoaded', this.boundScrollToLastViewedProduct);
|
|
68
|
+
window.removeEventListener('scroll', this.boundHandleScroll);
|
|
66
69
|
}
|
|
67
70
|
/**
|
|
68
71
|
* Set parsed filters data from URI
|
|
@@ -464,7 +467,7 @@ export class SallaProductsList {
|
|
|
464
467
|
this.loading(true, this.autoload ? false : true);
|
|
465
468
|
});
|
|
466
469
|
// Manual scroll listener
|
|
467
|
-
shouldApplyManualLoad && window.addEventListener('scroll', this.
|
|
470
|
+
shouldApplyManualLoad && window.addEventListener('scroll', this.boundHandleScroll);
|
|
468
471
|
this.infiniteScroll?.on('load', async (response) => {
|
|
469
472
|
if (this.isProcessing)
|
|
470
473
|
return;
|
|
@@ -517,14 +520,17 @@ export class SallaProductsList {
|
|
|
517
520
|
return;
|
|
518
521
|
this.scrollTimeout = setTimeout(() => {
|
|
519
522
|
this.scrollTimeout = null;
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
//
|
|
526
|
-
this.
|
|
527
|
-
|
|
523
|
+
// Defer layout reads to next frame to avoid forced reflow (Lighthouse/PageSpeed)
|
|
524
|
+
requestAnimationFrame(() => {
|
|
525
|
+
const wrapperRect = this.wrapper.getBoundingClientRect();
|
|
526
|
+
const windowHeight = window.innerHeight;
|
|
527
|
+
const distanceToBottom = wrapperRect.bottom - windowHeight;
|
|
528
|
+
// Trigger only when the wrapper bottom is within 200px of the viewport bottom
|
|
529
|
+
if (distanceToBottom <= 200 && !this.isProcessing && this.nextPage) {
|
|
530
|
+
// Reached near the bottom of the wrapper, loading next page...
|
|
531
|
+
this.manualLoadNextPage();
|
|
532
|
+
}
|
|
533
|
+
});
|
|
528
534
|
}, 200);
|
|
529
535
|
}
|
|
530
536
|
manualLoadNextPage() {
|