The idea is there are 5 sections named section1, section2 etc.
Each section has its own image.
When the user scrolls, the image should 'fade out' and in by changing the opacity, and there is a slight zoom in/out effect using transform3D.
I'm trying to acheive results identical to this:
My attempt at starting something is this
jQuery(document).ready(function() {
jQuery(window).scroll(function(event) {
let scroll = jQuery(this).scrollTop();
let opacity = 1 - (scroll / 1000);
var x = (scroll / 100);
if (opacity >= 0) {
jQuery('#section1').css({'opacity': opacity , 'transform': "scale(" + x + "," + x + ")"});
}
});
});
Now, this does create the opacity changing on effect when you scroll - the issue is, it applies to the whole page on scroll, but i want the effects to happen only when you user scrolls in/around the div with ID named section1
I know it;s applying to the whole window because the .scroll is being applied to jQuery(window). I have tried using jQuery('#section1') but if i do this nothing happens.
I have tried adding a transform3D effect like shown on http://www.moxhe.com.au/ but am struggling to get it work too, there should be a small decrease scrolling downwards and small increase scrolling upwards ONLY if user is scrolling around a specific div with the bg image.
Long story short, i need to make css animations identical to http://www.moxhe.com.au/ but am struggling with applying the css effects to a specific part of the page / div with an ID as supposed to the whole page.