I have a long bit of text on my page, and so I created a MultiState box and linked a Read More/Read Less button.
Here is the code I used:
$w . onReady ( function () {
$w ( “#readMoreButton” ). onClick (() => {
$w ( “#readMoreStatebox” ). changeState ( “expandedState” );
});
$w ( "#readLessButton" ). onClick (() => {
$w ( "#readMoreStatebox" ). changeState ( "collapsedState" );
});
})
It functions fine except for two issues:
- After clicking “Read Less,” it does not scroll back up to the top of the text.
- While the box is expanded, the webpage allows you to infinite scroll.
Any suggestions?
Thank you.
After clicking “Read Less,” it does not scroll back up to the top of the text.
To solve your first problem you can generate a function which would do the UPSCROLL.
Almost every of Wix-Elements has the —> " scrollTo() " function.
Use it for your purposes. Generate a code which will run when you need the scroll-action to any element-position on your page.
Here an example for a button…
https://www.wix.com/velo/reference/$w/button/scrollto
While the box is expanded, the webpage allows you to infinite scroll.
For second problem you may want to provide an example SCREENSHOT or even better an example-VIDEO to show your problem, since it is difficult to imagine whats going on, on your screen.