mark.palmos
posted this
2 days ago
Sorry for all the messages, but THIS one works best...
Replace your Site Settings > Additional HTML script with this. It is designed to be more aggressive about staying alive and finding the right path.
JavaScript
(function() {
function startEngine() {
// 1. Create the layer if it doesn't exist
let bg = document.getElementById('parallax-bg-layer');
if (!bg) {
bg = document.createElement('div');
bg.id = 'parallax-bg-layer';
document.body.prepend(bg);
}
function sync() {
const scrollVal = window.pageYOffset || document.documentElement.scrollTop;
// Speed 0.4.
const yOffset = -(scrollVal * 0.4);
bg.style.setProperty('transform', `translate3d(0, ${yOffset}px, 0)`, 'important');
}
// Run immediately to sync coordinates
sync();
// Continuous loop
function loop() {
sync();
window.requestAnimationFrame(loop);
}
window.requestAnimationFrame(loop);
}
// Fire as soon as possible
if (document.readyState === 'complete' || document.readyState === 'interactive') {
startEngine();
} else {
document.addEventListener('DOMContentLoaded', startEngine);
}
})();
THEN Paste this into your Page CSS:
#parallax-bg-layer {
position: fixed !important;
top: 0 !important;
left: 0 !important;
width: 100% !important;
height: 300vh !important; /* Extra height to prevent white gaps */
z-index: -10 !important;
/* We list BOTH possible paths here to be safe */
background-image: url('images/websitebackground3.jpg'), url('websitebackground3.jpg') !important;
background-size: cover !important;
background-position: center top !important;
background-attachment: scroll !important;
background-repeat: no-repeat !important;
display: block !important;
will-change: transform !important;
transition: none !important;
}
/* Force everything to be clear */
.u-body, .u-section, .u-sheet, section {
background-color: transparent !important;
background-image: none !important;
}
Last edited 2 days ago by Support Team