-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
71 lines (62 loc) · 1.72 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>功能演示</title>
<style>
.container {
width: 800px;
height: 500px;
border: 1px solid #666;
display: flex;
}
.box1 {
flex: 1;
background-color: red;
}
.box2 {
width: 300px;
height: 500px;
background-color: green;
}
.header {
height: 100px;
background-color: pink;
}
</style>
</head>
<body>
<div style="margin-bottom: 10px">
<button class="btn1">脱离</button>
<button class="btn2">还原</button>
</div>
<div class="container">
<div class="box1"></div>
<div class="box2" style="background-color: aqua">
<div class="header"></div>
</div>
</div>
<script type="module">
import DragResizeBox from "./dist/DragResizeBox.esm.js";
const boxEl = document.querySelector(".box");
const btn1El = document.querySelector(".btn1");
const btn2El = document.querySelector(".btn2");
const box2El = document.querySelector(".box2");
let dragResizeBox = null;
btn1El.addEventListener("click", () => {
dragResizeBox = new DragResizeBox(box2El, { center: true, dragSelector: ".box2>.header" });
dragResizeBox.addEventListener("resize", () => {
console.log("resize");
})
dragResizeBox.addEventListener("drag", () => {
console.log("drag");
})
});
btn2El.addEventListener("click", () => {
dragResizeBox.reset();
console.log(dragResizeBox);
});
</script>
</body>
</html>