亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

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

我無限滾動了一輪后會出現圖片位置不一樣,比如原來的index=1的圖片變到了index=3的位置

我無限滾動了一輪后會出現圖片位置不一樣,第一輪的情況正常,但是到了第二輪的時候,比如按下向右箭頭原來的index=1的圖片變到了index=3的位置或者其他位置,按下左箭頭也會出現這樣的情況.

window.onload=function(){
??????????? var container=document.getElementById('container');
??????????? var list=document.getElementById('list');
??????????? var buttons=document.getElementById('buttons').getElementsByTagName('span');
??????????? var next=document.getElementById('next');
??????????? var prev=document.getElementById('prev');
??????????? var index=1;
??????????? function animate(offset){
??????????????? var newLeft=parseInt(list.style.left)+offset;
??????????????? list.style.left=newLeft+'px';
??????????????? if(newLeft<-6000){
??????????????????? list.style.left=-1000+'px';
??????????????? }
??????????????? if(newLeft>-1000){
??????????????????? list.style.left=-6000+'px';
??????????????? }

??????????? }
??????????? function showButton(){
??????????????? for(var i=0;i<buttons.length;i++){
??????????????????? if(buttons[i].className=='on'){
??????????????????????? buttons[i].className='';
??????????????????????? break;
??????????????????? }
??????????????? }
??????????????? buttons[index-1].className='on';
??????????? }
??????????? next.onclick=function(){
???????????????
??????????????? if(index==5){
??????????????????? index=1;
??????????????? }
??????????????? else{
??????????????????? index+=1;
??????????????? }
??????????????? animate(-1000);
??????????????? showButton();
??????????? }
??????????? prev.onclick=function(){
???????????????
??????????????? if(index==1){
??????????????????? index=5;
??????????????? }
??????????????? else{
??????????????????? index-=1;
??????????????? }
??????????????? animate(1000);
??????????????? showButton();
??????????? }
??????????? for(var i=0;i<buttons.length;i++){
??????????????? buttons[i].onclick=function(){
??????????????????? if(this.className=='on'){
??????????????????????? return;
??????????????????? }
??????????????????? var myIndex=parseInt(this.getAttribute('index'));
??????????????????? var offset=-1000*(myIndex-index);
??????????????????? animate(offset);
??????????????????? index=myIndex;
??????????????????? showButton();
??????????????? }
??????????? }
??????? }


正在回答

2 回答

我也有出現這個問題。

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

把-6000換成-5000試試

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

舉報

0/150
提交
取消

我無限滾動了一輪后會出現圖片位置不一樣,比如原來的index=1的圖片變到了index=3的位置

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

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號