由于最近自己正在开发广告推广低代码平台,拖拽组件是必不可少的一个组成部分,为此个人进行了一些试验,用mouse事件模拟了尤大了那个clear的元素拖动效果。
直接上试验代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
#box {
width:1000px;
height:600px;
margin-left:auto;
margin-right:auto;
border: 1px solid black;
margin-top: 20px;
position: relative;
}
</style>
</head>
<body>
<div id="box"></div>
<script>
function sleep(time) {
let timeObj = new Date();
startTime = timeObj.getTime();
while(true) {
let timeObj1 = new Date();
curTime = timeObj1.getTime();
if(curTime > startTime + time) {
break;
}
}
}
var factory = function(){
let elms = [];
let stick = 4;
let fa = null;
let that = this;
function checkBound(h