perf: 优化长按菜单位置

This commit is contained in:
kuaifan 2025-04-10 07:46:32 +08:00
parent 54a42a14b6
commit 77940c9430
3 changed files with 10 additions and 7 deletions

View File

@ -1,6 +1,6 @@
<template>
<div class="page-manage" :class="pageClass">
<div class="manage-box-menu">
<div ref="boxMenu" class="manage-box-menu">
<Dropdown
class="page-manage-menu-dropdown main-menu"
trigger="click"
@ -1143,9 +1143,10 @@ export default {
this.operateItem = $A.isJson(projectItem) ? projectItem : {};
this.$nextTick(() => {
const rect = el.getBoundingClientRect();
const parentRect = this.$refs.boxMenu?.getBoundingClientRect() || {top: 0, left: 0}
this.operateStyles = {
left: `${event.clientX}px`,
top: `${rect.top + this.windowScrollY}px`,
left: `${event.clientX - parentRect.left}px`,
top: `${rect.top + this.windowScrollY - parentRect.top}px`,
height: rect.height + 'px',
}
this.operateVisible = true;

View File

@ -183,9 +183,10 @@ export default {
this.operateItem = $A.isJson(projectItem) ? projectItem : {};
this.$nextTick(() => {
const rect = el.getBoundingClientRect();
const parentRect = this.$el.getBoundingClientRect() || {top: 0, left: 0}
this.operateStyles = {
left: `${event.clientX}px`,
top: `${rect.top + this.windowScrollY}px`,
left: `${event.clientX - parentRect.left}px`,
top: `${rect.top + this.windowScrollY - parentRect.top}px`,
height: rect.height + 'px',
}
this.operateVisible = true;

View File

@ -1060,9 +1060,10 @@ export default {
this.operateVisible = false;
this.operateItem = $A.isJson(item) ? item : {};
this.$nextTick(() => {
const parentRect = this.$refs.list?.$el?.getBoundingClientRect() || {top: 0, left: 0}
this.operateStyles = {
left: `${clientX}px`,
top: `${rect.top + this.windowScrollY}px`,
left: `${clientX - parentRect.left}px`,
top: `${rect.top + this.windowScrollY - parentRect.top}px`,
height: rect.height + 'px',
}
this.operateVisible = true;