0

I am building a website on Wix that calls an API based on user input and renders the response into a new item in a Repeater.

Scrolling to anchor works but it's pretty bad. I am trying to get some smooth auto-scrolling working but I am stuck (see what I did there ;) :D)

This is what I have so far:

$w.onReady(async function () {
    //const userId = wixUsers.currentUser.id;
    //await getCurrentGeoLocation();
    //await getGeoLocationWeather();

    configureRepeater();
    await initiateAssistant();

    $w('#msgRepeater').onItemReady(($item, itemData, index) => {
        if(index === $w("#msgRepeater").data.length - 1) {
            $item('#chatMsg').scrollTo().then(() => {
                console.log("scroll to last item");
            });
        }
    });
});

function configureRepeater() {
    $w('#msgRepeater').data = repeaterItems;
    $w('#msgRepeater').onItemReady(($item, itemData, index) => {
        if(itemData.user == systemUser) {
            $item('#adminUserImg').show();
            $item('#guestUserImg').hide();
            $item('#assistantUserImg').hide();
        }
...

Debug log is displayed correctly when a new item is added to the Repeater but scrolling does not work. I am not too sure what I am doing wrong here. Any help is appreciated!

Bob Arnson
  • 21,377
  • 2
  • 40
  • 47
1000Suns
  • 251
  • 1
  • 3
  • 16

0 Answers0