Browse Source

fix: 菜单位置溢出的bug

xsx 6 tháng trước cách đây
mục cha
commit
c39a310e2f
1 tập tin đã thay đổi với 14 bổ sung2 xóa
  1. 14 2
      im-web/src/components/common/RightMenu.vue

+ 14 - 2
im-web/src/components/common/RightMenu.vue

@@ -26,9 +26,11 @@ export default {
 	},
 	methods: {
 		open(pos, items) {
-			this.pos = pos;
+			this.pos.x = pos.x;
+			this.pos.y = pos.y;
 			this.items = items;
 			this.show = true;
+			this.rejustPos();
 		},
 		close() {
 			this.show = false;
@@ -36,6 +38,16 @@ export default {
 		onSelectMenu(item) {
 			this.$emit("select", item);
 			this.close();
+		},
+		rejustPos() {
+			let menuH = this.items.length * 36;
+			let menuW = 100;
+			if (this.pos.y > window.innerHeight - menuH) {
+				this.pos.y = window.innerHeight - menuH;
+			}
+			if (this.pos.x > window.innerWidth - menuW) {
+				this.pos.x = window.innerWidth - menuW;
+			}
 		}
 	}
 }
@@ -75,4 +87,4 @@ export default {
 		}
 	}
 }
-</style>
+</style>