I’m sure this has been covered before but i cant find a solution anywhere. My client doesn’t want the page to scroll down when someone chooses an Anchor Link in the menu. She wants it to just load at that section on the page without loading the top of the page and then scrolling down. Wix’s stance on this, is it’s not supported.
I have tried adding a # to the end of the url but that doesn’t seem to work either.
Does anyone have a work around?
I cant believe this isn’t an option with so much control over every element of the site build. Any help welcomed.
You can use the wix-window-frontend
scrollTo()
function to scroll directly to x and y position, and also disable the animation.
Thanks for the reply. Would you be able to elaborate further as how to do this please. Many thanks I appreciate the help.
Here is a example of the scrollTo() function in use:
import wixWindow from 'wix-window';
$w.onReady(function () {
$w('#button1').onClick(() => {
wixWindow.scrollTo(0, 700, { "scrollAnimation": false });
})
});
This will make the page scroll to (X: 0, Y: 700) when a Button element with the ID #button1 is clicked. Please note the third optional parameter which disables the scroll animation.
Many thanks for taking the time. I have tried this and can’t seem to get it to work. I’m wanting it to work from a submenu not a button?