I’ve just started dabling with Wix Code. I’ve had a good search of the forum, but not found a match to my query:
On first arrival to my 1 page site, let the site load (nice image at top of page which takes a moment or two to load), wait for X seconds, then autoscroll to a defined anchor.
Is it possible?
Mill, this example waits two seconds and then proceeds to the anchor. You do want to place this in the page onReady function, which executes after all of the pages elements have loaded.
$w.onReady( function() {
setTimeout(function (parameter) {
$w("#anchor1").scrollTo()
}, 2000)
});
Thanks Anthonyb, much appreciated! I’ve noticed that this scrolls the anchor to the top of the screen, rather than stopping it at the header. Is there a way to address this?
Mill, I’m not entirely sure what you are trying to do, but try experimenting with different positions of the anchor. If it continues to function not how you want, maybe a screen shot would be helpful for us.
Hi Anthony, my description there was a bit ambiguous. What I meant to say was, the code appears to scroll the screen so the anchor specified ends up at the top pixel of the monitor, rather than to the bottom of the fixed header (header doesn’t move with page when scrolling) .
Thanks again.