06sortable.js delayOnTouchOnly属性
This commit is contained in:
parent
a5a61934a8
commit
951890a256
|
@ -0,0 +1,66 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<title>sortable.js delayOnTouchOnly属性例子</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: 80%;
|
||||||
|
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%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class="box">
|
||||||
|
<div id="g1" class="itxst">
|
||||||
|
<div>delayOnTouchOnly设置true在PC中delay属性无效</div>
|
||||||
|
<div class="item" data-id="1" onclick="del()">item 1</div>
|
||||||
|
<div class="item" data-id="2" onclick="del()">item 2</div>
|
||||||
|
<div class="item" data-id="3" onclick="del()">item 3</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="msg"></div>
|
||||||
|
<script>
|
||||||
|
//第一组
|
||||||
|
const g1 = document.getElementById("g1");
|
||||||
|
const ops = {
|
||||||
|
animation: 166,
|
||||||
|
draggale: ".item",
|
||||||
|
delay: 200,
|
||||||
|
delayOnTouchOnly: true,
|
||||||
|
// 拖拽结束
|
||||||
|
onEnd() {
|
||||||
|
const arr = sortable.toArray()
|
||||||
|
console.log(arr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const del = () => {
|
||||||
|
console.log("执行了del事件")
|
||||||
|
}
|
||||||
|
|
||||||
|
const sortable = Sortable.create(g1, ops)
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
2
temp.js
2
temp.js
|
@ -4,8 +4,10 @@
|
||||||
animation: 1000,
|
animation: 1000,
|
||||||
draggable: ".item",
|
draggable: ".item",
|
||||||
delay: 1000,
|
delay: 1000,
|
||||||
|
delayOnTouchOnly:true,
|
||||||
//拖动结束
|
//拖动结束
|
||||||
onEnd: function (evt) {
|
onEnd: function (evt) {
|
||||||
|
//可在浏览器中按F12查看evt对象结构
|
||||||
console.log(evt);
|
console.log(evt);
|
||||||
//获取拖动后的排序
|
//获取拖动后的排序
|
||||||
var arr = sortable1.toArray();
|
var arr = sortable1.toArray();
|
||||||
|
|
Loading…
Reference in New Issue