sortableJS/07sortable.js handle 指定拖拽句柄...

79 lines
2.0 KiB
HTML
Raw Permalink Normal View History

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>sortable.js handle属性例子</title>
<meta name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, minimal-ui">
<script src="https://www.itxst.com/package/sortable/sortable.min.js"></script>
<style>
.itxst {
margin: 10px auto;
width: 40%;
float: left;
margin-right: 10px;
}
.itxst>div {
padding: 6px;
background-color: #fdfdfd;
border: solid 1px #eee;
margin-bottom: 10px;
cursor: move;
}
#msg {
clear: both;
width: 100%;
}
.move {
float: left;
width: 100px;
background-color: #3a6bfd;
}
</style>
</head>
<body>
<div class="box">
<div> handle:".move" 点击A区域才能拖动</div>
<div id="g1" class="itxst">
<div class="item" data-id="1" onclick="del()">
<div class="move">A</div>
<div>item 1</div>
</div>
<div class="item" data-id="2" onclick="del()">
<div class="move">A</div>
<div>item 2</div>
</div>
<div class="item" data-id="3" onclick="del()">
<div class="move">A</div>
<div>item 3</div>
</div>
</div>
</div>
<div id="msg"></div>
<script>
//第一组
var g1 = document.getElementById('g1');
const ops = {
animation: 166,
draggable: ".item",
handle: ".move",
onEnd() {
const arr = sortable.toArray();
console.log(arr)
}
}
function del() {
console.log("执行了del事件")
}
const sortable = Sortable.create(g1, ops)
</script>
</body>
</html>