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

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

分享一下成功了的js代碼~~

window.onload?=?function?()?{
????var?container?=?document.getElementById('container');
????var?list?=?document.getElementById('list');
????var?buttons?=?document.getElementById('buttons').getElementsByTagName('span');
????var?prev?=?document.getElementById('prev');
????var?next?=?document.getElementById('next');
????var?index?=?1;

????/**
?????*?左右切換函數
?????*?@param?offset?左右的偏移量
?????*/
????var?offsetL?=?0;
????function?animate(offset)?{
????????var?oldLeft?=?parseInt(list.style.left);
????????var?newLeft?=?oldLeft?+?offset;
????????offsetL?=?oldLeft;
????????var?interval?=?null;
????????var?intervalNum?=?10;

????????//console.log('offsetL:?'?+?offsetL);
????????//console.log('newLeft:?'?+?newLeft);

????????//?向左切換動畫
????????if((offset?>?0)?&&?(offsetL?<?newLeft))?{
????????????//console.log('左');
????????????interval?=?setInterval(function?()?{
????????????????offsetL?+=?offset/(300/intervalNum);?//?300為移動的總時間

????????????????//console.log(offsetL);

????????????????list.style.left?=?offsetL?+?'px';

????????????????if(offsetL?==?newLeft)?{
????????????????????clearInterval(interval);

????????????????????//?兩個if語句實現了無限滾動
????????????????????if(newLeft?>?-600)?{
????????????????????????list.style.left?=?-3000?+?'px';
????????????????????}

????????????????????if(newLeft?<?-3000)?{
????????????????????????list.style.left?=?-600?+?'px';
????????????????????}
????????????????}
????????????},?intervalNum);
????????}

????????//?向右切換動畫
????????if((offset?<?0)?&&?(offsetL?>?newLeft))?{
????????????//console.log('右');
????????????interval?=?setInterval(function?()?{
????????????????offsetL?-=?-offset/(300/intervalNum);?//?300為移動的總時間

????????????????//console.log(offsetL);

????????????????list.style.left?=?offsetL?+?'px';

????????????????if(offsetL?==?newLeft)?{
????????????????????clearInterval(interval);
????????????????????//?兩個if語句實現了無限滾動
????????????????????if(newLeft?>?-600)?{
????????????????????????list.style.left?=?-3000?+?'px';
????????????????????}

????????????????????if(newLeft?<?-3000)?{
????????????????????????list.style.left?=?-600?+?'px';
????????????????????}
????????????????}
????????????},?intervalNum);
????????}
????}

????/**
?????*?小圓點切換函數
?????*/
????function?buttonsCtrl()?{
????????for(var?i?=?0;i?<?buttons.length;i++)?{
????????????if(buttons[i].className?==?'on')?{
????????????????buttons[i].className?=?'';
????????????}
????????}
????????buttons[index?-?1].className?=?'on';
????}


????//?左右切換的功能
????next.onclick?=?function?()?{
????????if(index?==?5)?{
????????????index?=?1;
????????}else?{
????????????index++;
????????}
????????buttonsCtrl();

????????animate(-600);
????};

????prev.onclick?=?function?()?{
????????if(index?==?1)?{
????????????index?=?5;
????????}else?{
????????????index--;
????????}
????????buttonsCtrl();

????????animate(600);
????};

????/**
?????*?點擊小圓點切換焦點圖
?????*/
????for(var?i?=?0;i?<?buttons.length;i++)?{
????????buttons[i].onclick?=?function?()?{
????????????if(this.className?==?'on')?{
????????????????return;?//?后面的語句不會再執行了,一直到buttonCtrl()都不會再執行
????????????}
????????????var?myIndex?=?this.getAttribute('index');
????????????var?offset?=?-600?*?(myIndex?-?index);
????????????animate(offset);

????????????//?index?更新到最新
????????????index?=?myIndex;

????????????//?小圓點變成橙色
????????????buttonsCtrl();
????????};
????}
};


正在回答

2 回答

在,求幫忙?

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

直接下載源代碼不久好了?

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

慕田峪2423336

怎么下載源代碼????
2017-05-11 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

分享一下成功了的js代碼~~

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

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

幫助反饋 APP下載

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

公眾號

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