I have created my first Webpage and featured a parallax/SplitScroll using ScrollMagic.js
When I use "developer tools" on chrome to view the page in mobile view, the parallax doesn't work as the triggers seem to be a bit off.
I've had a look online to see how I can fix the parallax in a mobile view and came across this Parallax scrolling not working on mobile css
From this answer, I have seen that parallaxes often do not work in mobile view. and it is recommended I disable the parallax when a certain viewport is reached.
As you can see on this codepen I have created https://codepen.io/Jaderianne/pen/jjgWpv when the screen is small (resize the browser) the text in the parallax view looks rather squashed so I think it would be best I disable the parallax when a certain viewport is reached.
As I am still learning web dev, and this is my first webpage I am unsure of how to disable the parallax when on a smaller screen. I think i'll need to use @media in my CSS but am unsure what needs to be enclosed in this..
Could someone help me, please?
The code is visible in my codepen which I have linked above.
Some of the HTML:
<section id="About" class="about">
<div class="about-title">
<h2>About Us</h2>
</div>
<div class="about-pages">
<div>
<h2>About 1</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Animi,
soluta ipsam, minima delectus eaque omnis!</p>
</div>
<div>
<h2>About 2</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Animi,
soluta ipsam, minima delectus eaque omnis!</p>
</div>
<div>
<h2>About 3</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Animi,
soluta ipsam, minima delectus eaque omnis!</p>
</div>
</div>
</section>
THE CSS CAN BE SEEN ON THE CODEPEN.
Javascript:
function splitScroll() {
const controller = new ScrollMagic.Controller();
new ScrollMagic.Scene({
duration: '200%',
triggerElement: '.about-title',
triggerHook: 0
})
.setPin('.about-title')
.addTo(controller)
new ScrollMagic.Scene({
duration: '200%',
triggerElement: '.services-title',
triggerHook: 0
})
.setPin('.services-title')
.addTo(controller)
}
splitScroll();
I would like About 1, About 2 and About 3 to appear directly under About Us, and vice versa for the Services section (when in mobile view)