JS Toggle visibility with onviewportEnter

Hi everyone,

I’m not a coder but, after some online research, I’ve succeded to set a javascript that let a series of text boxes (ID step2, step3…) to toggle the visibility of a series of hidden associated images (ID frame2, frame 3…) when the text enter the viewport, and to hide the images when they leave.

I would like to set the function so that it works only when the text boxes enter/leave the viewport from the bottom, not from the top.
Any help would be highly appreciated.
Thanks!

Riccardo

$w . onReady ( function () {
let fadeOptions = {
“duration” : 350 , “delay” : 150 , //time in ms
}
$w ( “#step2” ). onViewportEnter (()=>{
$w ( “#frame2” ). show ( “fade” , fadeOptions );
});

$w ( “#step2” ). onViewportLeave (()=>{
$w ( “#frame2” ). hide ( “fade” , fadeOptions );
});

$w ( “#step3” ). onViewportEnter (()=>{
$w ( “#frame3” ). show ( “fade” , fadeOptions );
});

$w ( “#step3” ). onViewportLeave (()=>{
$w ( “#frame3” ). hide ( “fade” , fadeOptions );

$w ( “#step4” ). onViewportEnter (()=>{
$w ( “#frame4” ). show ( “fade” , fadeOptions );
});

$w ( “#step4” ). onViewportLeave (()=>{
$w ( “#frame4” ). hide ( “fade” , fadeOptions );

});
});
});

Hey!

I’d recommend reaching out in the Velo forum. They might be able to provide more guidance there - https://community.wix.com/velo/forum

Hi Noah,

Thanks for your reply.
Ok, I thought both communities were connected inside the EditorX forum. In the meantime I’ve solved the problem in a different way (Chat GTP gave me a strong help).

I’ve make it override the fact that is not possible to access the DOM (included window/viewport information about size, position etc…), and generated a code that perfectly fitted the situation. I just did some minor changes to the design and it worked!