Jump to content
Search Community

ScrollTrigger with "sticky" image at bottom

AntAreS24 test
Moderator Tag

Go to solution Solved by Cassie,

Recommended Posts

Hi,

 

I'm new to GSAP and I'm trying to have a sticky image at the bottom for few sections, then make it fit with the rest of the page. I have a feeling the order of my divs or the structure is preventing the right pin spacing from happening.

 

What I'd like to happen is have the grass image pinned until the .img-placer marker, but have the image "fit" in between the .before and .after divs.

 

Once this is achieved, I'd like to replace this image with another image (I'm pretty sure using the onEnter and onLeave), but that's the next step, so I prefer to have the first step right.

 

Thanks for the help.

Ben

See the Pen qBppbEY by AntAreS24 (@AntAreS24) on CodePen

Link to comment
Share on other sites

Welcome to the forums, @AntAreS24. I read your post a few times and I'm still really fuzzy about what you're asking. Thanks for providing a demo. 

 

Looks like there's at least one typo - you had <dib /> instead of <div></div>

 

You mentioned you want the image to "fit in between .before and .after divs" but you have it in your markup at a totally different place. Is there some reason you don't just put it inbetween those in the markup? And I still don't understand the pinning effect you want, sorry. Maybe someone else understands and can offer some help. Here's a shot in the dark, though: 

 

See the Pen poppyZQ?editors=1010 by GreenSock (@GreenSock) on CodePen

 

Good luck with the project!

Link to comment
Share on other sites

Hi Jack,

 

Thanks for the quick response. Since I wasn't expecting since a quick response, I started working on another part of the project :D

I tried to draw what I want.

Step 1.

The "grass" image is sticky to the bottom of the red "title" screen. I want this grass to stay at the bottom until I reach the section 3.

1177291595_step1.thumb.png.6eacdcdea7fff2090310a74cac4b6b61.png

 

Step 2.

Once I reach the section 3, the image stays and fit between section 2 and 3.

343118428_step2.thumb.png.83ce8b361f624e54ead7e608f82be6ef.png

 

I looked at your sample, but I can't use a end trigger with +=100% as I have no idea how big will section 1 and 2 be, so I need to stop at the beginning of section 3.

 

Regards,

Ben

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...