I have a working solution where a link to a dynamic page successfully targets an item in a repeater on the target page (using wix location query) and scrolls down to it smoothly, (I had to put in a slight setTimeout delay to stop it scrolling back to the top of the page after!) but all the above I’m really happy with.
The problem is that the scrollTo takes the item too close to the top of the page. I’ve searched a lot around and see other people have this niggle too. I thought i’d simply use a .then and run a .scrollBy after to slip it back up the page a bit, but the animation looks terrible as the first portion (covered by the above events) is smooth, and the last ‘fix’ scrollBy snaps.
Can the .scrollBy be made to smoothly scroll rather than snap?
This is how it’s setup at the moment
import wixLocation from 'wix-location';
import wixWindow from 'wix-window';
let targetItem = wixLocation.query.item;
function scrollToRepeaterItem(itemId){
if(itemId !== undefined){
$w("#repeater1").forItems( [itemId], ($item, itemData, index) => {
$item("#container1").scrollTo()
.then( () => { wixWindow.scrollBy(0,-100) } );
})
}
}
$w.onReady(function () {
setTimeout(function (parameter) {
$w("#dataset1").onReady( () => {
scrollToRepeaterItem(targetItem);
});
}, 1600)
});
Thank you in advance for any help!