From fb86fc76143ff666fd47b6c0b8e57c5d9bf2d50e Mon Sep 17 00:00:00 2001 From: starknt <1431880400@qq.com> Date: Wed, 10 Jan 2024 16:03:58 +0800 Subject: [PATCH] feat: lazy load preview video --- src/components/VideoCard/VideoCard.vue | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/components/VideoCard/VideoCard.vue b/src/components/VideoCard/VideoCard.vue index 7a47c280..20f0beeb 100644 --- a/src/components/VideoCard/VideoCard.vue +++ b/src/components/VideoCard/VideoCard.vue @@ -52,6 +52,7 @@ const isHover = ref(false) // const dislikeReasonId = ref(null) const showPopCtrl = ref(false) const contentVisibility = ref<'auto' | 'visible'>('auto') +const mouseEnterTimeOut = ref() const mouseLeaveTimeOut = ref() const previewVideoUrl = ref('') @@ -100,13 +101,17 @@ function toggleWatchLater() { } function handleMouseEnter() { - isHover.value = true - clearTimeout(mouseLeaveTimeOut.value) - contentVisibility.value = 'visible' + mouseEnterTimeOut.value = setTimeout(() => { + mouseLeaveTimeOut.value = undefined + isHover.value = true + clearTimeout(mouseLeaveTimeOut.value) + contentVisibility.value = 'visible' + }, 1200) } function handelMouseLeave() { isHover.value = false + clearTimeout(mouseEnterTimeOut.value) clearTimeout(mouseLeaveTimeOut.value) mouseLeaveTimeOut.value = setTimeout(() => { contentVisibility.value = 'auto'