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

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

關于animate函數

? ?我可以這樣寫嗎

?animate(offset)?{

????????const?time?=?1000

????????const?rate?=?10

????????let?speed?=?offset/(time/rate)


????????let?goal?=?parseFloat(this.picBox.style.left)?-?offset


????????let?animate?=?setInterval(()?=>?{

????????????if?(?this.picBox.style.left?==?goal?||?Math.abs(Math.abs(parseFloat(this.picBox.style.left))?-?Math.abs(goal))?<?Math.abs(speed)?)?{

????????????????this.picBox.style.left?=?goal?+?"px"

????????????????clearInterval(animate)

???????????????


????????????}?else?{

????????????????this.picBox.style.left?=?parseFloat(this.picBox.style.left)?-?speed?+?"px"

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

????????},?rate)


????}

這樣移動看上去順暢些

正在回答

1 回答

?

if?(?this.picBox.style.left?==?goal?||?Math.abs(Math.abs(parseFloat(this.picBox.style.left))?-?Math.abs(goal))?<?Math.abs(speed)?)?{

????????????????this.picBox.style.left?=?goal?+?"px"

????????????????clearInterval(animate) ? ? ? ? ? ? ??

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

這個可以加px吧,為什么下面加上面不加

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

舉報

0/150
提交
取消
手把手從0打造電商網頁開發
  • 參與學習       16982    人
  • 解答問題       58    個

手把手教你實現電商網站開發之高仿京東商城網頁

進入課程

關于animate函數

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

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

幫助反饋 APP下載

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

公眾號

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