Jump to content
Search Community

GSAP Help - ScrollTrigger not performing as expected.

COG Digital test
Moderator Tag

Recommended Posts

Hi all, I'm hoping to get some assistance so that I can have a fake horizontal scroll work. Ideally, I want to not be able to scroll past this horizontal scroll until I've reached the end of the section and then continue scrolling vertically.

 

I'm using Wordpress with Divi themebuilder. I've read all of the fourms and demos and tried multiple solutions however none seem to operate as expected. I've done a codepen to showcase my CSS and JS. However as my HTML is not raw, and rather done with Divi builder, I've added a screenshot to show the representation of data that I currently have. 

 

Currently, the section is where the #gsap-horizontal-section id has been placed. I've then added the css classes ".gsap-x" on each row. 

 

Hoping this makes sense and that someone can assist! 

 

Thanks in advance. 

 

 

gsap-ScrollTrigger.PNG

See the Pen dyZWXKg by cogbranding (@cogbranding) on CodePen

Link to comment
Share on other sites

Hi OSUBlake, thanks for the response. So I've made a loom for you to watch how its actually occurring on my website. 

 

Like it works, but the start and end aren't correct. AND I can scroll past the section. It should stop at that section until I've scrolled through and then continue the vertical scroll.

 

https://www.loom.com/share/f54c196a87604294ba324ed0a86da493

Link to comment
Share on other sites

It looks like the container isn't being pinned in your video, but I don't know how to recommend fixing that as it works in the demo, and we can really make suggestions based on code we can see in context. The only thing that I can that think that might be messing with it is some of the classes or inline styles on or around the container like in a parent element.

 

 

 

  • Like 1
Link to comment
Share on other sites

4 minutes ago, OSUblake said:

The only thing that I can that think that might be messing with it is some of the classes or inline styles on the container.

 

As an example, I wrapped everything in a div that has transform style on it, which will break the fixed positioning.

 

See the Pen GROMMOo by GreenSock (@GreenSock) on CodePen

 

It's not a GSAP issue, it's just how CSS works.

 

https://stackoverflow.com/questions/15194313/transform3d-not-working-with-position-fixed-children"

 

 

  • Like 1
Link to comment
Share on other sites

Thanks again for the response. I totally understand what you mean as I've read through the docs and forums. I can see GSAP working and on scroll adding the fixed positioning and transforming as expected. 

 

Prior to the scroll on the trigger container, there is no transform or positioning set, so for me its a real head scratcher. I'm not sure if it has to do with the flex but I guess I will just have to continue working on various ways to get it working as expected. 

Link to comment
Share on other sites

So I was able to solve this on Wordpress for anyone else interested. I used a model from the demos and then tweeked it to get it to work in the page builder.

 

In Divi, I needed to have a section with a row and a code block, with all my code and styling inside as per codepen below. 

 

See the Pen BammQZj by cogbranding (@cogbranding) on CodePen

 

 

  • Like 1
  • Thanks 1
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...