[討論] Google Maps程式碼

看板Web_Design作者 (life goes on)時間9年前 (2016/03/31 04:09), 編輯推噓4(404)
留言8則, 6人參與, 最新討論串1/1
https://developers.google.com/maps/documentation/javascript/markers#animate 想請問下面這行程式碼要如何理解呢?(黃標處) function toggleBounce() { if (marker.getAnimation() !== null) { marker.setAnimation(null); } else { marker.setAnimation(google.maps.Animation.BOUNCE); } } ps. 文件說明: BOUNCE 指出標記在原地彈跳。 彈跳標記會持續彈跳,直到它的 animation 屬性明確設成 null 才會停止。 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 219.84.234.215 ※ 文章網址: https://www.ptt.cc/bbs/Web_Design/M.1459368560.A.DC2.html

03/31 14:51, , 1F
如果marker.getAnimation()的回傳值不等於null
03/31 14:51, 1F

03/31 14:52, , 2F
應該是指 maker.animation !== null
03/31 14:52, 2F

03/31 14:54, , 3F
即是判斷marker.animation是否為null(有沒有東西)
03/31 14:54, 3F

03/31 15:04, , 4F
本來在跳的變成不跳,不跳的讓他開始跳
03/31 15:04, 4F

04/01 01:20, , 5F
如果有值(!==null)就把它設成null
04/01 01:20, 5F

04/01 03:00, , 6F
謝謝大家,web板真溫馨
04/01 03:00, 6F

04/01 17:03, , 7F
可以理解為hasAnimation()或isAnimated()吧
04/01 17:03, 7F

04/01 21:08, , 8F
看function name嘛~toggle就是on->off off->on
04/01 21:08, 8F
文章代碼(AID): #1M_39mt2 (Web_Design)
文章代碼(AID): #1M_39mt2 (Web_Design)