Thanks for the hint, landairsea.
I just added in the gk.scripts.js at the section
parallax_layer.css 'margin-top': '200px', and 'background-position': 'center', and now it looks like, that it works fine for me.
- Code: Select all
// New parallax engine
if(jQuery(window).width() > 640) {
jQuery(document).ready(function() {
var parallax_containers = [];
var parallax_heights = [];
var parallax_tops = [];
var window_h = jQuery(window).outerHeight();
var parallax_progress = [];
var parallax_layers = [];
jQuery('.parallax-bg').each(function(i, parallax_wrap) {
parallax_wrap = jQuery(parallax_wrap);
// check the wrapper
if(!parallax_wrap.children('.box-wrap').length) {
parallax_wrap.html('<div class="box-wrap">' + parallax_wrap.html() + '</div>');
}
// don't add position: relative to the tabs content
if(!parallax_wrap.parent().hasClass('gkTabsItem')) {
parallax_wrap.parent().css('position', 'relative');
}
var content = parallax_wrap.children('.box-wrap');
var parallax_layer = jQuery('<div class="parallax-bg-layer"></div>');
parallax_layer.css('background-image', parallax_wrap.css('background-image'));
parallax_wrap.css({
'background-image': '',
'z-index': '1'
});
parallax_layer.css({
'width': '100%',
'height': '130%',
'position': 'absolute',
'z-index': '0',
'margin-top': '200px',
'background-position': 'center',
'top': '0',
'background-size': 'cover'
});
parallax_layer.appendTo(parallax_wrap.parent());
parallax_containers.push(parallax_wrap);
});
jQuery(parallax_containers).each(function(i, container) {
container = jQuery(container);
parallax_heights.push(container.outerHeight());
parallax_tops.push(container.offset().top);
parallax_layers.push(jQuery(container.parent().find('.parallax-bg-layer')));
});
jQuery(window).resize(function() {
jQuery(parallax_containers).each(function(i, container) {
container = jQuery(container);
parallax_heights.push(container.outerHeight());
parallax_tops.push(container.offset().top);
});
});
jQuery(window).scroll(function() {
var scroll = jQuery(document).scrollTop();
jQuery(parallax_tops).each(function(i, top) {
if(
scroll >= top - window_h &&
scroll <= top + parallax_heights[i]
) {
var progress = (scroll - (top + window_h)) / (top + parallax_heights[i]);
jQuery(parallax_layers[i]).css('top', parallax_heights[i] * progress + 'px');
}
});
});
var scroll = jQuery(document).scrollTop();
jQuery(parallax_tops).each(function(i, top) {
if(
scroll >= top - window_h &&
scroll <= top + parallax_heights[i]
) {
var progress = (scroll - (top + window_h)) / (top + parallax_heights[i]);
jQuery(parallax_layers[i]).css('top', parallax_heights[i] * progress + 'px');
}
});
});
}