我在我的网站上使用 jQuery scrollify 插件。它工作得很好,但我需要为页面的不同区域设置自定义偏移量。例如,我所有的部分元素的偏移量应为 -200,而 2页脚元素的偏移量应为 -100px 和 -50px。这不能仅通过使用 interstitialSection 来实现。任何人都可以为此提出解决方案吗?
HTML
<header>
....
</header>
<section>
</section>
....
//removed for brevity
....
<footer class="contact">
</footer>
<footer class="social-footer">
</footer>
JS
$.scrollify({
section: "header, section, footer",
interstitialSection: "header, section, .contact, .social-footer",
offset: -200,
//this doesn't seem to work
before: function (indexPosition, snapToElm) {
if (indexPosition === 1) {
snapToElm[indexPosition].css({ "margin-top": "200px" });
} else if (indexPosition === 2) {
snapToElm[indexPosition].css({ "margin-top": "100px" });
} else if (indexPosition === 3) {
snapToElm[indexPosition].css({ "margin-top": "150px" });
}
},
afterRender: function () {
//Picked up from another source
//set the first element initially to the desired offset
$($(this.section)[0]).css({ "margin-top": "200px" });
}
});