Variable/Case logic for scroll position?

I’m trying to program a “scroll to top” button in a prototype, but I’m not able to get it to hide when the user manually scrolls to the top. There’s a screenshot of my logic below. My problem is that I am looking to write a case that says “If the window is scrolled all the way up, hide the button”. What I have now is just the delta scroll, but I am looking for a way to express the scroll position; not the amount of scroll.

I am aware of some workarounds, such as using the area of the TOP button over a hidden item in the window, but am looking for a more elegant solution. To clarify, the problem is when the user manually scrolls up, I don’t want the button to appear until they scroll ALL THE WAY up.

Thanks! Gregory

You can use the built-in variable, [[Window.scrollY]] to get the current vertical scroll position of the browser window, and [[This.scrollY]] to get the current vertical scroll position of a dynamic panel–or rather, for the dynamic panel to get its own scroll value. If you need another widget to get the scroll position of a dynamic panel, you’d use a local variable in the expression, like [[LVAR1.scrollY]]

I see in your Scrolled Up event you are testing [[This.scrollX]] which would give the horizontal scroll of that dynamic panel. Maybe that’s a typo? If you change it to .scrollY your logic should work.

It’s not a typo. I don’t make typos! What that is is abject stupidity! I can’t believe I did that! So "scrollY’ IS the absolute position of the scroll. It’s amazing how I concocted a complex explanation why it didn’t work as I expected, and all it was was mixing up X and Y. THANKS! Tested, and works as expected.

1 Like