Problem with Paralax effect continued ... - Forum | JoomShaper
Staff replied SP Page Builder

Problem with Paralax effect continued ...

Asked by Tomasz Michałowski 5 years ago Last activity 5 years ago

there is always a problem with Paralax effect background.
Empty space appears when scrolling the page
when the screen is vertical.
browsers: computer : chrome, firefox, ie ...
smartphone : android

video: https://cdx.pl/parallax.webm

7 replies

Toufiq Senior Staff

Hi there,

Thanks for contacting us. Your administrator access does not work. Even it does not show any error while i try to login.

-Thanks

Tomasz Michałowski Asked this

I checked it works.

Toufiq Senior Staff

It does not work for me :(

Tomasz Michałowski Asked this

maybe on this page

Tomasz Michałowski Asked this

I found my own solution - code below. I am begging you to do it in your own script or write where the function is Parallax- in what file. the problem is concerned background Position

$('[data-sppb-parallax]').each(function() {
$(this).removeAttr('data-sppb-parallax');
$(this).addClass('js-parallax-bg');
});

var images = [].slice.call(document.querySelectorAll('.js-parallax-bg'));

function getViewportHeight() {
var a = document.documentElement.clientHeight, b = window.innerHeight;
return a < b ? b : a;
}

function getViewportScroll() {
if(typeof window.scrollY != 'undefined') {
return window.scrollY;
}
if(typeof pageYOffset != 'undefined') {
return pageYOffset;
}
var doc = document.documentElement;
doc = doc.clientHeight ? doc : document.body;
return doc.scrollTop;
}

function doParallax() {
var el, elOffset, elHeight,
offset = getViewportScroll(),
vHeight = getViewportHeight();

for(var i in images) {
    el = images[i];
    elOffset = el.offsetTop;
    elHeight = el.offsetHeight;

    if((elOffset > offset + vHeight) || (elOffset + elHeight < offset)) { continue; }
    pos_par = Math.round((elOffset - offset)*3/5);

if(pos_par>0){
el.style.backgroundPosition = '50% '+pos_par+'px';
}

}

}

$(window).scroll(function () {
doParallax()
})

Tomasz Michałowski Asked this

has the fault been repaired?

Toufiq Senior Staff

Hi there, I have forward your ticket to our developer team. I hope they will take care your issue. Thanks

Log in to reply.