mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-18 08:12:15 +00:00
contextmenu fix
This commit is contained in:
@@ -3,10 +3,10 @@
|
|||||||
v-show="isVisible"
|
v-show="isVisible"
|
||||||
:style="{ top: positionY + 'px', left: positionX + 'px' }"
|
:style="{ top: positionY + 'px', left: positionX + 'px' }"
|
||||||
@click="closeAndResetContextMenu"
|
@click="closeAndResetContextMenu"
|
||||||
class="absolute z-20 w-60 overflow-hidden rounded-xl bg-white shadow-lg dark:bg-2x-dark-foreground select-none"
|
class="fixed z-20 w-60 select-none overflow-hidden rounded-xl bg-white shadow-lg dark:bg-2x-dark-foreground"
|
||||||
ref="contextmenu"
|
ref="contextmenu"
|
||||||
>
|
>
|
||||||
<div id="menu-list" class="w-full">
|
<div class="w-full">
|
||||||
<!--Show empty select contextmenu-->
|
<!--Show empty select contextmenu-->
|
||||||
<slot name="empty-select" v-if="!item" />
|
<slot name="empty-select" v-if="!item" />
|
||||||
|
|
||||||
@@ -52,32 +52,13 @@ export default {
|
|||||||
this.item = undefined
|
this.item = undefined
|
||||||
},
|
},
|
||||||
showContextMenu(event) {
|
showContextMenu(event) {
|
||||||
let parent = document.getElementById('menu-list')
|
let menu = this.$refs.contextmenu
|
||||||
let nodesSameClass = parent.getElementsByClassName('menu-option')
|
|
||||||
|
|
||||||
let VerticalOffsetArea = nodesSameClass.length * 50
|
let hiddenAreaX = window.innerWidth - event.clientX - menu.clientWidth - 25
|
||||||
let HorizontalOffsetArea = 190
|
let hiddenAreaY = window.innerHeight - event.clientY - menu.clientHeight - 25
|
||||||
|
|
||||||
let container = document.getElementById('file-view')
|
this.positionX = hiddenAreaX < 0 ? event.clientX + hiddenAreaX : event.clientX
|
||||||
|
this.positionY = hiddenAreaY < 0 ? event.clientY + hiddenAreaY : event.clientY
|
||||||
let offset = container.getClientRects()[0]
|
|
||||||
|
|
||||||
let x = event.clientX - offset.left
|
|
||||||
let y = event.clientY - offset.top
|
|
||||||
|
|
||||||
// Set position Y
|
|
||||||
if (container.offsetHeight - y < VerticalOffsetArea) {
|
|
||||||
this.positionY = y - VerticalOffsetArea
|
|
||||||
} else {
|
|
||||||
this.positionY = y
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set position X
|
|
||||||
if (container.offsetWidth - x < HorizontalOffsetArea) {
|
|
||||||
this.positionX = x - HorizontalOffsetArea
|
|
||||||
} else {
|
|
||||||
this.positionX = x
|
|
||||||
}
|
|
||||||
|
|
||||||
// Show context menu
|
// Show context menu
|
||||||
this.isVisible = true
|
this.isVisible = true
|
||||||
@@ -100,9 +81,10 @@ export default {
|
|||||||
this.isVisible = !this.isVisible
|
this.isVisible = !this.isVisible
|
||||||
|
|
||||||
if (this.isVisible) {
|
if (this.isVisible) {
|
||||||
let container = document.getElementById('folder-actions')
|
let container = document.getElementById('folder-actions').getBoundingClientRect()
|
||||||
|
|
||||||
this.positionX = container.offsetLeft
|
this.positionX = container.x
|
||||||
|
this.positionY = container.y + 20
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
'-translate-x-4 opacity-0': !currentFolder || !isNotHomepage,
|
'-translate-x-4 opacity-0': !currentFolder || !isNotHomepage,
|
||||||
'translate-x-0 opacity-100': currentFolder && isNotHomepage,
|
'translate-x-0 opacity-100': currentFolder && isNotHomepage,
|
||||||
}"
|
}"
|
||||||
class="ml-3 transform rounded-md bg-light-background py-0.5 px-1.5 transition-all duration-200 dark:bg-dark-foreground cursor-pointer"
|
class="relative ml-3 transform rounded-md bg-light-background py-0.5 px-1.5 transition-all duration-200 dark:bg-dark-foreground cursor-pointer"
|
||||||
id="folder-actions"
|
id="folder-actions"
|
||||||
>
|
>
|
||||||
<more-horizontal-icon size="14" />
|
<more-horizontal-icon size="14" />
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<li
|
<li
|
||||||
class="flex items-center justify-between py-4 px-5 lg:py-3 2xl:py-4"
|
class="flex items-center justify-between py-4 px-5"
|
||||||
:class="{'group cursor-pointer hover:bg-light-background dark:hover:bg-4x-dark-foreground': !isHoverDisabled,}"
|
:class="{'group cursor-pointer hover:bg-light-background dark:hover:bg-4x-dark-foreground': !isHoverDisabled}"
|
||||||
>
|
>
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
<div class="mr-4">
|
<div class="mr-4">
|
||||||
|
|||||||
Reference in New Issue
Block a user