使用以下HTML:
<body>
<header>...</header>
<div class="do-sectionScroll1">...</div>
<div class="do-sectionScroll2">...</div>
<div class="do-sectionScroll3">...</div>
<footer>...</footer>
</body>
我希望在<header>
和<footer>
中自由滚动,但我想将其锁定到do-sectionScroll。因此,用户必须在<div>
之后滚动<div>
,就像一页滚动一样。
我没有找到任何插件来做到这一点。许多插件都是一页滚动,而不是<div>
滚动。
我该怎么做?
编辑:
我在http://jsfiddle.net/promo/mb8nh6sh/3/创建了一个我想要做的事情的逻辑示例......
编辑2:
我想做的事情应该是这样的:
jQuery(document).ready(function ($) {
$(document).on('scroll', function(){
/*
IF SCROLL TO THE BOTTOM
if $(window).scrollTop() < header.height
do nothing special
if $(window).scrollTop() > header.height
scroll to do-sectionScroll1
if $(window).scrollTop() go to bottom AND do-sectionScroll1 reached
scroll to do-sectionScroll2
if $(window).scrollTop() go to bottom AND do-sectionScroll2 reached
scroll to do-sectionScroll3
if $(window).scrollTop() go to bottom AND footer reached
do nothing special
IF SCROLL TO THE TOP
if $(window).scrollTop() go to top AND do-sectionScroll3 reached
scroll to do-sectionScroll2
if $(window).scrollTop() go to top AND do-sectionScroll2 reached
scroll to do-sectionScroll1
if $(window).scrollTop() go to top AND header reached
do nothing special
etc ...
*/
};
});