Hello
I'm trying out some if and else statements on my website. My Goal is that if the user hasn't scrolled it scrolls after 3sec. If he scrolls to a certain point the function above shouldn't be triggered at all.
Unfortunately I'm not very good at js so I'm having a hard time solving the problem.
$w.onReady( function() {
if ($w("#button1").rendered{
return
} else {
setTimeout(function (parameter) {
$w("#anchor1").scrollTo()
}, 2000)
}
});
I'm trying to check if button1 is on viewport with the rendered statement. Unfortunately it is giving me an error there.
Can someone help me solving this problem?
Thank you very much
It occurred to me to use setInterval instead of setTimeout. You need to be able to get in there and evaluate if the user has scrolled after three seconds. SetTimeout cannot do that; it just blindly fires after three seconds. The viewportEnter event needs to be on a suitable element down the page where you can set the UserScrolled variable to true.
Raphi,
There were a couple syntax modifications needed. Hopefully, this gets you a little closer to your goal.
$w.onReady(function () { if ($w("#button1").rendered) { // nothing } else { setTimeout(function (parameter) { $w("#anchor1").scrollTo() }, 3000) } });