美文网首页
边框拖拽功能

边框拖拽功能

作者: 辉色星空下 | 来源:发表于2023-12-05 15:19 被阅读0次
    <template>
      <div>
          <div
                class="configration mr-10"
                id="configration"
                @mousedown="mousedown"
              >
                <div class="min-h-box">
                  
                </div>
              </div>
      </div>
    </template>
     mounted() {
        document.addEventListener("mouseup", this.mouseUp);
      },
    methods: {
      mouseUp() {
          document.removeEventListener("mousemove", this.mouseMove);
        },
        mouseMove(event) {
          let configration = document.getElementById("configration");
          let configValue = document.getElementById("configValue");
          let dialog = document.getElementsByClassName("dialogResize")[0];
          let endX = event.clientX;
          //弹窗的宽度
          let dialogWidth = dialog.style.width.substring(
            0,
            dialog.style.width.lastIndexOf("px")
          );
          let moveLen = this.startLeft + (endX - this.startX);
          if (moveLen > 200) {
            configration.style.width = moveLen + "px";
            configValue.style.width = Number(dialogWidth) - moveLen + "px";
          }
        },
        mousedown(event) {
          this.startX = event.clientX;
          this.startLeft = event.offsetX;
          document.addEventListener("mousemove", this.mouseMove);
        },
    
    }
        ```

    相关文章

      网友评论

          本文标题:边框拖拽功能

          本文链接:https://www.haomeiwen.com/subject/vgrdgdtx.html