2 Commits 0af3ac6293 ... d2f414bb26

Author SHA1 Message Date
  rui.jiang d2f414bb26 222 1 month ago
  rui.jiang 9d400f57f2 111 1 month ago
1 changed files with 8 additions and 9 deletions
  1. 8 9
      src/components/map/index.vue

+ 8 - 9
src/components/map/index.vue

@@ -357,27 +357,26 @@ export default {
     },
     initEvent() {
       let lastHoveredFeature = null;
-
-      function calculateHoverTop(mouseY, hoverHeight) {
-        const windowHeight = window.innerHeight;
+      const calculateHoverTop = (mouseY, hoverHeight) => {
+        const componentHeight = this.$el.clientHeight;
         const offset = 10;
-        if (mouseY + hoverHeight + offset > windowHeight) {
+        if (mouseY + hoverHeight + offset > componentHeight) {
           return mouseY - hoverHeight - offset;
         }
         return mouseY - hoverHeight / 2;
-      }
+      };
 
-      function calculateHoverLeft(mouseX, hoverWidth) {
-        const windowWidth = window.innerWidth;
+      const calculateHoverLeft = (mouseX, hoverWidth) => {
+        const componentWidth = this.$el.clientWidth;
         const offset = 10;
-        if (mouseX + hoverWidth + offset > windowWidth) {
+        if (mouseX + hoverWidth + offset > componentWidth) {
           return mouseX - hoverWidth - offset;
         }
         if (mouseX - hoverWidth - offset < 0) {
           return offset;
         }
         return mouseX + offset;
-      }
+      };
       this.map.on("pointermove", (evt) => {
         const features = this.map.getFeaturesAtPixel(evt.pixel, {
           hitTolerance: 1,