-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathindex.html
More file actions
99 lines (86 loc) · 1.96 KB
/
index.html
File metadata and controls
99 lines (86 loc) · 1.96 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>demo</title>
<style>
* {
margin: 0;
padding: 0;
}
html,
body {
width: 100%;
height: 100%;
}
.container {
width: 100%;
height: 100%;
}
.box {
width: 200px;
height: 200px;
border: 1px dashed #ccc;
left: 50px;
top: 50px;
}
.content {
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
font-size: 28px;
}
.dragHandle {
width: 15px;
height: 15px;
border-radius: 50%;
background: #000;
position: absolute;
left: 0;
top: -15px
}
.resizeHandle {
display: block;
position: absolute;
width: 10px;
height: 10px;
border-right: 2px solid #b2b2b2;
border-bottom: 2px solid #b2b2b2;
right: 0px;
bottom: 0px;
overflow: hidden;
cursor: nw-resize;
}
</style>
</head>
<body>
<div class="container">
<div class="box">
<div class="content">
Candy
</div>
<div class="dragHandle">
</div>
<div class="resizeHandle">
</div>
</div>
</div>
</body>
</html>
<script src="./drag.js">
</script>
<script>
let container = document.querySelector(".container");
let elem = document.querySelector(".box")
let dragHandle = document.querySelector(".dragHandle")
let resizeHandle = document.querySelector(".resizeHandle")
new Draggable(container, elem, dragHandle, resizeHandle, true, (dragStyle) => {
console.log("Location of the current element after dragging(当前元素拖拽后的位置)", dragStyle)
}, (resizeStyle) => {
console.log("The size of the current element after dragging(当前元素拖拽后的大小)", resizeStyle)
});
</script>