This is a read-only archive of the Framer Community on Facebook.

What is Framer? Join the Community
Return to index
Chris Calo
Posted Apr 14 - Read on Facebook

Howdy, all.

If I have an instance of a ScrollComponent, how would I find out what the *maximum* scroll position can be?

In the code attached, notice that by inspecting the values of scroll.scrollX I was able to figure out that in this case its maximum value is 194, but I'd now like to compute this number—or read it from a property!

Anyone have any tips? I'm not able to find anything in the docs on this.

3 Comments

George Kedenburg III

i think this should scroll.content.height - Screen.height?

Manuel Dahm

i didnt really read your code but normally that number would be the height of your object minus the available visible area
something like
object.height - viewport.height

that should always be a positive number otherwise no need for scrolling.

Chris Calo

🙏 Thanks, George Kedenburg III and Manuel Dahm! With your tips I was able to figure out the general solution:

scrollXMax = Math.max(scroll.content.width - scroll.width, 0)
scrollYMax = Math.max(scroll.content.height - scroll.height, 0)

Read the entire post on Facebook