Hello,
I am assessing a few strategies for implementing parallax effects and came across the GSAP ScrollTrigger examples.
The simple parallax sections examples works nicely when the sections occupy 100vh, but I run into issues when making the sections smaller.
In the codepen example, the sections are set to occupy 60vh and they look fine in a wide view, but when the window is as narrow as possible, white spaces appear within the sections, ruining the effect.
It is my understanding that the narrow viewport issue occurs because the background image dimensions are similar to the section dimensions, and so there is no natural overflow from background-size: cover.
Has anyone experienced and overcome this issue before?
Other strategies I've tried:
1) background-attachment: fixed, this is the most simple approach
2) setting background-size to 'auto 140%' (any second value greater than 100%), and then animating fromTo backgroundPosition: '50% 100%' => backgroundPosition: '50% 0%'. This works well in most cases but, the width will be restricted on larger viewports.
I think the gsap examples look the most elegant, but I am struggling to overcome the white space issue and am hoping someone may be able to provide some guidance.
Thank you in advance for any help.