Hi Joe,
I modified the code a bit so it will apply to all blocks with the parallax class, but please be noted it’s a question that is out of our support forum scope, we are trying our best to help 🙂
Make sure you wrap the code with <script> and </script> tags when adding to the hook element.
window.addEventListener('scroll', throttle(parallax, 14));
function throttle(fn, wait) {
var time = Date.now();
return function() {
if ((time + wait - Date.now()) < 0) {
fn();
time = Date.now();
}
}
};
function parallax() {
var scrolled = window.pageYOffset;
var parallaxElements = document.querySelectorAll(".parallax");
// Iterate over all parallax elements and update their positions
parallaxElements.forEach(function(element) {
var coords = (scrolled * 0.4) + 'px';
element.style.transform = 'translateY(' + coords + ')';
}); };