When socket messages come, I pop up divs in my page which disposes after 3 seconds themselves
<!-- I'm using vuejs -->
<div v-for='item in messageList'>
<!-- message body , -->
</div>
// used to pause timer when mouseEnter and resume when mouseLeave
const mesTimerMap = new Map()
const messageList = ref([])
socket.on('message',function(mesBody){
messageList.value.push(mesBody)
let timer = setTimeout(()=>{
handleRemove(mesBody) // in which I splice messageList
},3000)
mesTimerMap.set(mesBody.id,timer)
})
But I found that if I switch to other tabs and here comes a message, when I change back to my page, the pop up is still there even 3 seconds already passed. And I can not replicate this every time. Why is that?