22 lines
611 B
JavaScript
22 lines
611 B
JavaScript
export default function useContinuousClickLive() {
|
|
const addContinuousClickLive = (boxClass) => {
|
|
const b = Math.floor(Math.random() * 6) + 1
|
|
const bl = Math.floor(Math.random() * 11) + 1 // bl1~bl11
|
|
|
|
let d = document.createElement("div")
|
|
d.className = `bubble b${b} bl${bl}`
|
|
d.dataset.t = String(Date.now())
|
|
const likeBox = document.querySelector(boxClass)
|
|
likeBox.appendChild(d)
|
|
;((d) => {
|
|
d.addEventListener("animationend", () => {
|
|
if (likeBox.contains(d)) {
|
|
likeBox.removeChild(d)
|
|
}
|
|
})
|
|
})(d)
|
|
}
|
|
|
|
return addContinuousClickLive
|
|
}
|