我有一個Flexslider可容納項目的所有內容。在這種情況下,每個「頁面」或幻燈片具有不同的內容,如更新,項目,關於和聯繫。Flexslider body scroll僅適用於當前幻燈片(V2)
這些頁面有不同的長度,有些需要滾動條,有些則不需要。在不需要滾動的頁面上,內容下方有大量空白空間。這個空間被內容佔據在其他頁面上。
我使用jQuery來查找li.flex-active-slide
和窗口的高度,並且這工作正常。如果在點擊導航欄時li.flex-active-slide
類發生變化,我無法弄清楚如何告訴jQuery。
這裏是我的Flexslider代碼:
$(document).ready(function() {
//set some variables for calculating the hash
var index = 0, hash = window.location.hash;
//via malsup (Cycle plugin), calculates the hash value
if (hash) {
index = /\d+/.exec(hash)[0];
index = (parseInt(index) || 1) - 1;
}
$(window).trigger('resize');
$('#mainflexslider').flexslider({
animation: "fade",
slideDirection: "horizontal",
keyboardNav: false,
slideshow: false,
animationSpeed: 500,
controlsContainer: ".flex-container",
manualControls: ".flex-control-nav li",
startAt: index,
after:function(slider){
window.location.hash = slider.currentSlide+1;
}
});
});
(旁註:。而點擊進入導航信貸的問題及相應的答案是here網址正在更新)
而對於尋找身高:
$(window).load(function() {
var slideHeight = $("li.flex-active-slide").height();
var windowHeight = $(window).height();
if (slideHeight > windowHeight) {
$('html, body').css('overflowY', 'auto');
}
else {
$('html, body').css('overflowY', 'hidden');
}
});
我想知道是否有辦法將這兩個代碼結合起來?
如果不是,Flexslider在追加li.flex-active-slide
類時如何判斷jQuery?
你可以把代碼找回後面的高度回調 –