Jump to content
Search Community

ScrollTrigger Dynamic calculations help

xxeg test
Moderator Tag

Go to solution Solved by Trapti,

Recommended Posts

I have a gallery of "projects" that I want to scroll horizontally. However, a (common) isssue I am running into is that when I resize the window, the scroll does not go all the way, such that the right side of items gets clipped out of the window. I tried employing common methods of fixing this via calculations through functions for xPercent and end() however this did not work.

 

I am not sure if this is attributed to the way my project divs are styled but I was wondering what are some common ways to ensure the items will scroll all the way regardless of window size? Ideally, I want to the gallery to start with the first item in the center, and end with the final item in the center. Similarly to this website https://aristidebenoist.com/

 

I am not sure what direction I should go in fixing this problem either. Usually, I can break up these problems into subproblems to simplify it down. However, I am not sure if I should go about fixing the window problem or centering the project divs first. Any help would be much appreciated :)

See the Pen VwqJPPK by agl13 (@agl13) on CodePen

Link to comment
Share on other sites

I see. Thank you for the response! I see how you used display grid instead of what I did with flex. However, I am still unable to ensure the last item still does not end in the center. I am still not sure what to do about since the position of that item varies depending on window size.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...