wickes-css2 2.106.0-IC-1222-back-functionality-poc.2 → 2.106.0-IC-1222-back-functionality-poc.3

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.
@@ -109,7 +109,7 @@ Wick.PLPLoadMore = {
109
109
  url.searchParams.delete(Wick.PLPLoadMore.RESTORE_PRODUCT_PARAM);
110
110
 
111
111
  if (state.loadedCount <= Wick.PLPLoadMore.MAX_VISIBLE) {
112
- url.searchParams.set('perPage', state.loadedCount);
112
+ url.searchParams.set('perPage', 120);
113
113
  url.searchParams.set(Wick.PLPLoadMore.RESTORE_MODE_PARAM, 'perPage');
114
114
  } else {
115
115
  const clickedPage = Math.floor((state.clickedIndex - 1) / Wick.PLPLoadMore.STEP);
@@ -350,8 +350,8 @@ Wick.PLPLoadMore = {
350
350
  Wick.PLPLoadMore.currentPage = nextPage;
351
351
 
352
352
  const cardsCount = Wick.PLPLoadMore.getCardsCountInDOM();
353
+
353
354
  Wick.PLPLoadMore.setPerPage(cardsCount);
354
- Wick.PLPLoadMore.setPageParam(Wick.PLPLoadMore.currentPage);
355
355
 
356
356
  Wick.PLPLoadMore.updateLoadPreviousVisibility();
357
357
  Wick.PLPLoadMore.toggleLoadMoreBtn();
@@ -453,7 +453,15 @@ Wick.PLPLoadMore = {
453
453
  },
454
454
 
455
455
  initCurrentPage() {
456
- Wick.PLPLoadMore.currentPage = Wick.PLPLoadMore.getPageParam();
456
+ const params = new URLSearchParams(window.location.search);
457
+
458
+ if (params.has('page')) {
459
+ Wick.PLPLoadMore.currentPage = Number(params.get('page')) || 0;
460
+ return;
461
+ }
462
+
463
+ const perPage = Wick.PLPLoadMore.getPerPage();
464
+ Wick.PLPLoadMore.currentPage = Math.max(0, Math.ceil(perPage / Wick.PLPLoadMore.STEP) - 1);
457
465
  },
458
466
 
459
467
  handleRestoreScroll() {