我想循环遍历同一个类的div列表,到目前为止我已经设法解决了这个问题。
但是,一旦我向下滚动到div类型的最后一个,我想启动一个函数。
这是代码:
public Priority getPriority() {
return priority;
}
一旦我到达最后一个.sub-section我想执行函数nextMainSection();
编辑:如果有更好的帮助,这里是整个代码:
$('#mcbatchsubscribe').on('click', 'a.ajaxresub', function (e) {
e.preventDefault();
var email = $(this).attr('emailvalue');
$.ajax ({
url: '/admin/ajax/ajax_resubscribe.php',
data: {email: email},
dataType: 'json',
success: function (json) {
console.log("success", json);
//alert(json)
}
} );
} );
根据请求,这里是实时代码。当你到达黑色区域时,在google dev下你会看到类激活很好,只需要通过激活前面提到的函数向下滚动它:http://www.onethousandsheep.com/stackoverflow
答案 0 :(得分:0)
我最终这样做了:
jQuery的:
function prevSection(event) {
//go to previous section
typeof event !== 'undefined' && event.preventDefault();
var visibleSection = sectionsAvailable.filter('.visible'),
middleScroll = (hijacking == 'off' && $(window).scrollTop() != visibleSection.offset().top) ? true : false;
visibleSection = middleScroll ? visibleSection.next('.cd-section') : visibleSection;
var animationParams = selectAnimation(animationType, middleScroll, 'prev');
unbindScroll(visibleSection.prev('.cd-section'), animationParams[3]);
//-----(My Added) Previous SUB-SECTION-----//
if ($('#what-section').hasClass('visible')) {
$('.sub-section').filter('.opacity').removeClass('opacity').prev().addClass('opacity');
$('.sub-section').filter('.visible').prev('.sub-section').removeClass('up').addClass('visible');
$('.sub-section').filter('.visible').next('.sub-section').removeClass('visible');
if ($('.triggerSection').hasClass('opacity')) {
prevSectionSub();
$('.triggerSection').removeClass('opacity visible');
$('.sub-section:first').addClass('opacity visible');
}
} else if (!animating && !visibleSection.is(":first-child")) {
prevSectionSub();
}
//-----END-----//
function prevSectionSub() {
animating = true;
visibleSection.removeClass('visible').children('div').velocity(animationParams[2], animationParams[3], animationParams[4])
.end().prev('.cd-section').addClass('visible').children('div').velocity(animationParams[0], animationParams[3], animationParams[4], function () {
animating = false;
if (hijacking == 'off') $(window).on('scroll', scrollAnimation);
});
actual = actual - 1;
}
resetScroll();
}
function nextSection(event) {
//go to next section
typeof event !== 'undefined' && event.preventDefault();
var visibleSection = sectionsAvailable.filter('.visible'),
middleScroll = (hijacking == 'off' && $(window).scrollTop() != visibleSection.offset().top) ? true : false;
var animationParams = selectAnimation(animationType, middleScroll, 'next');
unbindScroll(visibleSection.children('.cd-section'), animationParams[3]);
//-----(My Added) Next SUB-SECTION-----//
if ($('#what-section').hasClass('visible')) {
$('.sub-section').filter('.opacity').removeClass('opacity').next().addClass('opacity visible');
$('.sub-section').filter('.visible').prev('.sub-section').removeClass('visible').addClass('up');
if ($('.triggerSection').hasClass('opacity visible')) {
nextSectionSub();
$('.triggerSection').removeClass('opacity visible');
$('.sub-section:last').addClass('opacity visible');
}
} else if (!animating && !visibleSection.is(":last-of-type")) {
nextSectionSub();
}
//-----END-----//
function nextSectionSub() {
animating = true;
visibleSection.removeClass('visible').children('div').velocity(animationParams[1], animationParams[3], animationParams[4])
.end().next('.cd-section').addClass('visible').children('div').velocity(animationParams[0], animationParams[3], animationParams[4], function () {
animating = false;
if (hijacking == 'off') $(window).on('scroll', scrollAnimation);
});
actual = actual + 1;
}
resetScroll();
}
HTML:
<div class="triggerSection"></div>
<div class="sub-section opacity visible">
<div class="outer">
<div class="middle">
<div class="header-text">
<h1>Title</h1>
<p>Text</p>
</div>
</div>
</div>
</div>
<div class="sub-section">
<div class="outer">
<div class="middle">
<div class="header-text">
<h1>Title</h1>
<p>Text</p>
</div>
</div>
</div>
</div>
<div class="sub-section">
<div class="outer">
<div class="middle">
<div class="header-text">
<h1>Title</h1>
<p>Test</p>
</div>
</div>
</div>
</div>
<div class="triggerSection"></div>
它不漂亮,它是黑客,我显然不是开发人员。使用键盘向上和向下箭头,鼠标滚动是错误的,因为JQ没有考虑CSS转换延迟并且在每个子部分被激活后没有重置滚动(如果有人想要关注我和#39;感恩:)。