最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

為了賬號安全,請及時綁定郵箱和手機立即綁定

求解,有bug

window.onload?=?function(){
	var?container?=?document.getElementById("container"),
		list?=?document.getElementById("list"),
		btn?=document.getElementById("btn").getElementsByTagName("span"),
		prev?=?document.getElementById("prev"),
		next?=?document.getElementById("next"),
		index?=?1,
		animated?=?false,
		timer;
		
	//圓點的函數(shù)
	function?showButton(){
		//清除圓點屬性
		for(var?i?=?0;?i?<?btn.length;?i++){
			if(btn[i].className?==?'on'){
				btn[i].className?=?'';
				break;
			}
		}
		btn[index?-?1].className?=?'on';
	}
	//點擊圓點切換圖片
	for(var?i?=?0;?i?<?btn.length;?i++){
		btn[i].onclick?=?function(){
			//條件成立,退出函數(shù),后面的將不執(zhí)行
			if(this.className?==?'on'){
				return;
			}
			//獲取當前點擊的index值
			var?myIndex?=?parseInt(this.getAttribute('index'));
			var?offset?=?-960?*?(myIndex?-?index);
			animate(offset);
			index?=?myIndex;
			if(!animated){
				showButton();
			}
		}
	}
	//封裝點擊箭頭切換圖片的函數(shù)
	function?animate(offset){

		animated?=?true;
		var?newLeft?=?parseInt(list.style.left)?+?offset;
		var?time?=?300;		//位移總時間
		var?interval?=?5;		//位移間隔時間
		var?speed?=?offset/(time/interval);??//每次位移量
		
		function?go(){
			if(speed?<?0?&&?parseInt(list.style.left)?>?newLeft?||?speed?>?0?&&?parseInt(list.style.left)?<?newLeft){
				list.style.left?=?parseInt(list.style.left)?+?speed?+?"px";
				setTimeout(go,interval);
			}else{
				animated?=?false;
				list.style.left?=?newLeft?+?"px";
				//無限滾動
				if(newLeft?>?-960){
					list.style.left?=?-4800?+?"px";
				}
				if(newLeft?<?-4800){
					list.style.left?=?-960?+?"px";
				}
			}
		}
			go();
	}
	
	//自動切換函數(shù)
	function?play(){
		timer?=?setInterval(function(){
			next.onclick();
		},1500);
	}
	//清除定時器
	function?stop(){
		clearInterval(timer);
	}
	
	//點擊右箭頭
	next.onclick?=?function(){
		if(!animated){
		if(index?==?5){
			index?=?1;
		}else{
			index?+=?1;
		}
		showButton();
			animate(-960);
		}
	}
	//點擊左箭頭
	prev.onclick?=?function(){
		if(!animated){
		if(index?==?1){
			index?=?5;
		}else{
			index?-=?1;
		}
		showButton();
			animate(960);
		}
	}
	container.onmouseover?=?stop;
	container.onmouseout?=?play;
	play();
}

這里有個bug求解,點擊圓點圖片跳轉沒問題,但是不會高亮,要點兩次才會亮起來,,求解

正在回答

1 回答

32-36行應該是:

?? ? ? ? ? ?index?=?myIndex;

?????????????showButton();?

????????????if(!animated){

????????????????animate(offset);

????????????}

上一個動畫執(zhí)行完了才可以執(zhí)行? animate(offset);

而你上面的是 動畫不在執(zhí)行的時候才能執(zhí)行showButton(); 點第一次時在執(zhí)行動畫,這個時候執(zhí)行不了?showButton(); 點第二次時沒在執(zhí)行動畫然后執(zhí)行了?showButton(); 所以出現(xiàn)你那種情況。


0 回復 有任何疑惑可以回復我~
#1

小白菜v 提問者

嗖嘎,原來如此,,跟老師視頻就是這樣寫的/笑哭??
2017-07-11 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消
焦點圖輪播特效
  • 參與學習       65344    人
  • 解答問題       638    個

通過本教程學習您將能掌握非常實用的焦點圖輪播特效的制作過程

進入課程

求解,有bug

我要回答 關注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號