1.0.4 • Published 3 years ago

drag_modal_element v1.0.4

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

drag_modal_element 拖拽弹窗框位置

installation

npm install --save-dev drag_modal_element

use

以 vue 为例

<template>
  <div class="showContent">
    <h1>hello</h1>
    <div class="dragBox" id="dragBox">
      <div class="dragBox__header" id="dragBox__header">按住这里拖拽</div>
    </div>
  </div>
</template>

<script>
import DragElement from "drag_modal_element";

let dragControl;
let listenerBack;

export default {
  name: "Model",
  mounted() {
    this.installDrag();
  },
  destroyed() {
    this.unInstallDrag();
  },
  methods: {
    installDrag() {
      dragControl = new DragElement(document.getElementById("dragBox"));
      listenerBack = dragControl.bind(
        document.getElementById("dragBox__header")
      );
    },
    unInstallDrag() {
      if (dragControl) {
        dragControl.unBind(
          document.getElementById("dragBox__header"),
          listenerBack
        );
        dragControl = null;
      }
    },
  },
};
</script>

<style>
* {
  margin: 0;
  padding: 0;
}

body,
html {
  overflow: hidden;
  width: 100%;
  height: 100%;
}
</style>

<style scoped>
.showContent {
  width: 600px;
  height: 600px;
  border: 1px solid;
  margin-left: 50px;
  margin-top: 50px;
  position: relative;
}
.dragBox {
  position: absolute;
  width: 200px;
  height: 200px;
  border: 1px solid;
  background: red;
  left: 0;
  top: 300;
}
.dragBox__header {
  width: 100%;
  height: 40px;
  background-color: blue;
  line-height: 40px;
  text-align: center;
  color: #fff;
}
</style>

演示示例

1.0.4

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.3

3 years ago

1.0.0

3 years ago