Show/Hide a button on page when scrolling >200px from the top

@jonatandor35 Thanks a lot again J.D.

I have done this, and works perfectly but I dont know if it is “js friendly” or if there is a better/other way :

1) I have added a button on one of my page and “copy-past” it on all my pages. The button have the same ID (#buttonScrolltop) in all my pages

2) Then I have named all my 1st Sections (sectionheader) on all my pages with the same ID (#sectionTop)

3) Then I put the code (your code) into MasterPage.js

//button scroll to the top
$w . onReady (() => {
$w ( ‘#sectionTop’ ). onViewportLeave (()=> {
$w ( ‘#buttonScrolltop’ ). show ( “fade” );
})
$w ( ‘#sectionTop’ ). onViewportEnter (()=> {
$w ( ‘#buttonScrolltop’ ). hide ( “fade” );
})
})

… and works perfectly :smiley:

Thousand thanks and best regards

Sébastien