Hi,
I have a pagination bar that controls a repeater. I have the gallery set so each page displays 30 photos before you go to the next page. Unfortunately, after a user scrolls through all the photos on a given page and then clicks on the pagination bar to go to the next page, the next page is already scrolled all the way down instead of starting at the top.
Is there a way to code the page to always go back up to the top of the page once a new “page” of photos is loaded?
Thank you!
I am using this code:
import wixWindow from ‘wix-window’;
$w.onReady( function () {
$w(‘#pagination1’).onClick(() => {
$w(‘#header1’).scrollTo();
})
});
The thing is it says that ‘onClick’ does not exist in ‘#pagination1’ , but I cannot see how to turn on onClick function on pagination1. What could I do with that please?
Thank you!
Hi Karel, I just came across your post and it helped me figure out how to scroll up as I scroll through my pages. If you haven’t gotten this fixed yet, here’s what I did and it worked. I had to add an “onClick” function to my 2 pagination buttons in the Properties Panel and made the names of them “nextbutton_click” and “previousbutton_click”.
It hasn’t clicked for me yet why sometimes it’s “onClick” and sometimes it’s “_click”, but I just make sure whatever function I’m writing into my code matches what’s written in the Properties Panel.
export function nextbutton_click(event, $w) {
let index = $w(“#dataset1”).getCurrentItemIndex();
$w(“#dataset1”).setCurrentItemIndex(index + pageSize)
$w(“#pagetitletext”).scrollTo();
}
export function previousbutton_click(event, $w) {
let index = $w(“#dataset1”).getCurrentItemIndex();
$w(“#dataset1”).setCurrentItemIndex(index - pageSize);
$w(“#pagetitletext”).scrollTo();
}
I hope this helps you, as your code helped me!
Hi, may i know what pageSize is? I applied this code to my site but it doesn’t work all the time. It will either scroll to the top before loading the next page items or it will load the next page item but then jumps back to previous page. Please help