(function ($) {
var $container = $(".parallax");
var $divs = $container.find("div.parallax-background");
var liHeight = $divs.eq(0).closest("li").height();
var diffHeight = $divs.eq(0).height() - liHeight;
var i, len, div, li, offset, scroll, top;
var render = function () {
top = $(window).scrollTop();
for (i = 0, len = $divs.length; i < len; i++) {
div = $divs[i];
li = div.parentNode;
offset = $(div).offset().top;
scroll = Math.round(((top - offset) / liHeight) * diffHeight);
div.style.webkitTransform = "translate3d(0px," + scroll + "px,0px)";
}
};
(function loop() {
requestAnimationFrame(loop);
render();
})();
})(jQuery);
我发现了一个脚本并试图弄清楚为什么它不适用于firefox。能帮到我吗?