我有這個功能(transComplete),它執行突出顯示相關指示器的任務,顯示用戶它們在哪個頁面上,這些控制器/指示器的每個元素代表一個頁面,並將適當突出顯示。Javascript邏輯在一個循環/ if語句
這個工作是獨立的,但是當我引入一個點擊功能,它允許與指示器進行交互以在頁面之間移動時,它可以正確導航,但不會根據需要進行突出顯示(只能每兩次點擊),這導致我相信它的邏輯問題我的代碼。
的布爾邏輯真/假是原因,突出顯示只發生在該變量的「真」的情況下「isOnSecond」,所以我基本上需要一個解決方案點擊
的時總是突出的相關控制器主要功能是如下:
功能transComplete(){
slideTransStep = 0;
crtSlideIndex = nextSlideIndex;
// for IE filters, removing filters re-enables cleartype
if (nextSlide.style.removeAttribute) {
nextSlide.style.removeAttribute("filter");
// show next slide
showSlide((crtSlideIndex >= totalSlides) ? 1 : crtSlideIndex + 1);
//Highlights a nav circle every two transitions as the boolean alternates
if (isOnSecond == true) {
//unhighlight all controls
for (var i = 0; i < slidesControllersCollection.length; i++) {
if (slidesControllersCollection[i].className === slideHighlightClass) {
slidesControllersCollection[i].className = "";
}
// highlight the control for the next slide
document.getElementById("slide-control-" + crtSlideIndex).className = slideHighlightClass;
}
isOnSecond = false;
}
else {
isOnSecond = true;
}
}
的onclick功能:
function clickSlide(control) {
showSlide(Number(control.id.substr(control.id.lastIndexOf("-")+1)),true);
}
我應該不是寫在這裏。當你調用showSlide時,你有這個檢查'((crtSlideIndex> = totalSlides)''''''''''''''''''''.getElementById(「slide-control-」+(crtSlideIndex> = totalSlides?1: crtSlideIndex + 1))。className' – Atle