forked from Mirrors/elk
fix: autoplay video only when on screen (#624)
This commit is contained in:
parent
4787250df0
commit
121c90fc3a
1 changed files with 3 additions and 3 deletions
|
@ -66,12 +66,12 @@ useIntersectionObserver(video, (entries) => {
|
|||
return
|
||||
|
||||
entries.forEach((entry) => {
|
||||
if (entry.intersectionRatio !== 1 && !video.value!.paused)
|
||||
video.value!.pause()
|
||||
if (entry.intersectionRatio <= 0.75)
|
||||
!video.value!.paused && video.value!.pause()
|
||||
else
|
||||
video.value!.play()
|
||||
})
|
||||
}, { threshold: 1 })
|
||||
}, { threshold: 0.75 })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
Loading…
Reference in a new issue