//maybe this one?? https://developers.google.com/web/updates/2016/12/performant-parallaxing // lib var betaParallax = function(){} betaParallax.elementPartVisible = function(el){ var rect = el.getBoundingClientRect(); var totalPixels = window.innerHeight + rect.height; var activePixel = window.innerHeight - rect.top; return activePixel / totalPixels; // 0 = element under the bottom, 1 = element above the top } betaParallax.positionize = function(el, maxPixel){ var part = betaParallax.elementPartVisible(el); if (part < -0.1 || part > 1.1) return; var faktor = (part - .5)*2; // -1 bis 1; var child = el.c1Find('>.-image'); //var children = el.children; //for (var i=0, child; child = children[i++];) { // has to be made once... child.style.top = - maxPixel / 2 + 'px'; child.style.bottom = - maxPixel / 2 + 'px'; //child.style.transition = 'transform 10ms linear'; var value = faktor*maxPixel; value = value.toFixed(1); child.style.webkitTransform = 'translate3d(0, '+value+'px, 0)'; child.style.transform = 'translate3d(0, '+value+'px, 0)'; //} } cms.initCont('cms.cont.parallax1', function(el){ var wrapper = el.c1Find('> .-viewport'); if (!wrapper) return; function positionize(e){ if (!wrapper.offsetParent) { // disconnected from the dom document.removeEventListener('scroll', positionize, {passive: true}); removeEventListener('resize', positionize); removeEventListener('load', positionize); } betaParallax.positionize(wrapper, 360); } positionize(); document.addEventListener('scroll', positionize, {passive: true}); addEventListener('resize', positionize); addEventListener('load', positionize); wrapper.c1Find('>.-image').addEventListener('load',positionize); });