mui事件实现拖动元素

<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.min.css" rel="stylesheet" />
		<style>
			#box{
				background: #007AFF;
				width:100px;
				height:100px;
				position: absolute;
				top:200px;
				left:100px;
			}
		</style>
	</head>

	<body>
		
		<div id="box"></div>
		<script src="js/mui.min.js"></script>
		<script type="text/javascript">
		
			var box = document.getElementById("box");
			
			mui.init({
				gestureConfig: {
					tap: true, //默认为true
					doubletap: true, //默认为false
					longtap: true, //默认为false
					swipe: true, //默认为true
					drag: true, //默认为true
					hold: false, //默认为false,不监听
					release: false //默认为false,不监听
				}
			});
		</script>

		<script type="text/javascript">
			var y = box.getBoundingClientRect().top;
			var x = box.getBoundingClientRect().left;
			
			mui("body").on('dragstart', '#box', function(v) {
				// 每次开始拖动之前更新位置
				y = box.getBoundingClientRect().top;
				x = box.getBoundingClientRect().left;
			})
			
			mui("body").on('drag', '#box', function(v) {
				console.log(v.detail.deltaX,v.detail.deltaY)
				
				// 根据拖动的位置 修改当前box的y坐标 和 x坐标
				box.style.top = (y+v.detail.deltaY)+"px";
				box.style.left = (x+v.detail.deltaX)+"px";
			})
		</script>
	</body>

</html>