<template>
  <div class="context-module" v-show="contextVisible" @click="closeContextMenu">
    <div class="context-wrap">
      <el-popover
        v-model="contextVisible"
        placement="right-start"
        width="200"
        trigger="manual"
        transition="el-zoom-in-left"
        popover-class="content-popover-area"
      >
        <div @click="handleGetBig">大图标</div>
        <div @click="handleGetMedium">中等图标</div>
        <div @click="handleGetSmall">小图标</div>
        <div
          slot="reference"
          class="context-module-button"
          :style="{
            left: eventPosition.left + 'px',
            top: eventPosition.top + 'px',
          }"
        ></div>
      </el-popover>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    contextVisible: {
      type: Boolean,
    },
    eventPosition: {
      type: Object,
    },
  },
  mounted() {
    console.log("this.contextVisible", this.contextVisible);
  },
  data() {
    return {
      labelPosition: "right",
    };
  },
  methods: {
    closeContextMenu() {
      console.log("关闭");
      this.$emit("changeVisible", false);
    },
    handleGetBig() {
      console.log("大图标关闭");
      this.$emit("changeSize", "300");
      this.$emit("changeVisible", false);
    },
    handleGetMedium() {
      console.log("中等图标关闭");
      this.$emit("changeSize", "200");
      this.$emit("changeVisible", false);
    },
    handleGetSmall() {
      console.log("小图标关闭");
      this.$emit("changeSize", "100");
      this.$emit("changeVisible", false);
    },
  },
};
</script>

<style lang="scss" scoped>
.context-module {
  position: fixed;
  z-index: 999;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  .context-wrap {
    position: relative;
    width: 100%;
    height: 100%;
  }
  .context-module-button {
    position: absolute;
    width: 1px;
    height: 1px;
  }
}

.content-popover-area {
  transform-origin: 0 0 !important;
}
.content-popover-area > div {
  font-size: 12px;
  cursor: pointer;
  line-height: 26px;
  &:hover {
    color: skyblue;
  }
}
</style>
<style lang="scss">
.el-popover {
  background-color: skyblue;
  div {
    font-size: 12px;
    cursor: pointer;
    line-height: 26px;
    &:hover {
      color: #fff;
    }
  }
}
</style>
