Skip to content

Commit

Permalink
fix(VideoCard): preview control cannot be dragged while pressing (Bew…
Browse files Browse the repository at this point in the history
…lyBewly#714)

* fix(VideoCard): preview control cannot be dragged while pressing

* Update VideoCard.vue

---------

Co-authored-by: Hakadao <[email protected]>
  • Loading branch information
lzy1960 and hakadao authored May 5, 2024
1 parent 6cd2e4e commit e37caa7
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/components/VideoCard/VideoCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ const emit = defineEmits<{
const api = useApiClient()
// Used to click and control herf attribute
const isClick = ref<boolean>(false)
const videoUrl = computed(() => {
if (!isClick.value)
return undefined
if (props.bvid || props.aid)
return `https://www.bilibili.com/video/${props.bvid ?? `av${props.aid}`}`
else if (props.epid)
Expand Down Expand Up @@ -149,6 +154,17 @@ function handelMouseLeave() {
}, 300)
}
function switchClickState(flag: boolean) {
if (flag) {
isClick.value = flag
}
else {
setTimeout(() => {
isClick.value = flag
})
}
}
function handleMoreBtnClick(event: MouseEvent) {
emit('moreClick', event)
}
Expand Down Expand Up @@ -212,6 +228,9 @@ function handleUndo() {
:href="videoUrl" target="_blank" rel="noopener noreferrer"
@mouseenter="handleMouseEnter"
@mouseleave="handelMouseLeave"
@mousedown="switchClickState(true)"
@mouseup="switchClickState(false)"
@dragend="switchClickState(false)"
>
<!-- Cover -->
<div
Expand Down

0 comments on commit e37caa7

Please sign in to comment.