更改视口大小后,Parallax.js背景出现了位移

问题描述

我正在使用PixelCog的parallax.js。在我的网站上,如果我立即更改了视口的大小,例如通过单击“最大化”窗口选项,或将我的浏览器窗口大小固定为显示器的一半,视差背景的位置不会更新。 parallax.js使用“视差镜”类创建的div最终出现在错误的位置:

image showing the background div in the wrong position relative to the correct div (should be behind join the community)

我试图将以下内容添加到我的JS中:

jQuery(window).trigger('resize').trigger('scroll');

但这没什么区别。我的视差是这样初始化的:

   jQuery(document).ready(function($){

$('.parallax.cover,.parallax.hero').each(function(){
    image = $(this).data('background-image');
    $(this).parallax({imageSrc: image,position: 'center top' });
    $(this).addClass('initialised');
  })
  jQuery(window).trigger('resize').trigger('scroll');
});

在视差块上唯一可以说的CSS是:

    .parallax {
    min-height: 100px;
    position:relative;
    background-position:center;
} 
parallax.initialised {
        background-image: none !important;
        background-color:transparent !important;
    }

我已经仔细检查过一次,并且窗口调整大小事件正在触发,只是此视差功能无法相应地调整自身。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)