Compare commits
No commits in common. "e8fc5a4b448a571e24b173237d2ad23758715186" and "951890a2569ff5513b79df764de1b6ecddbe39a4" have entirely different histories.
e8fc5a4b44
...
951890a256
|
@ -1,79 +0,0 @@
|
||||||
<!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>
|
|
|
@ -1,72 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<title>sortable.js filter属性例子</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: 70%;
|
|
||||||
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 id="g1" class="itxst">
|
|
||||||
<div> item 2 无法被拖动 class包含了filter类</div>
|
|
||||||
<div class="item" data-id="1">
|
|
||||||
item 1
|
|
||||||
</div>
|
|
||||||
<div class="item filter" data-id="2">
|
|
||||||
item 2
|
|
||||||
</div>
|
|
||||||
<div class="item" data-id="3">
|
|
||||||
item 3
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div id="msg"></div>
|
|
||||||
<script>
|
|
||||||
//第一组
|
|
||||||
const g1 = document.getElementById('g1');
|
|
||||||
const ops1 = {
|
|
||||||
animation: 166,
|
|
||||||
delay: 30,
|
|
||||||
draggable: ".item",
|
|
||||||
filter: ".filter",
|
|
||||||
onEnd() {
|
|
||||||
const arr = sortable1.toArray();
|
|
||||||
console.log(arr)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const sortable1 = Sortable.create(g1, ops1);
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
|
@ -1,77 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<title>sortable.js filter属性自定义函数例子</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: 70%;
|
|
||||||
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 id="g1" class="itxst">
|
|
||||||
<div>filter属性自定义函数限制了 item 2 无法被拖动</div>
|
|
||||||
<div class="item" data-id="1">
|
|
||||||
item 1
|
|
||||||
</div>
|
|
||||||
<div class="item" data-id="2">
|
|
||||||
item 2
|
|
||||||
</div>
|
|
||||||
<div class="item" data-id="3">
|
|
||||||
item 3
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div id="msg"></div>
|
|
||||||
<script>
|
|
||||||
//第一组
|
|
||||||
const g1 = document.getElementById('g1');
|
|
||||||
const ops1 = {
|
|
||||||
animation: 166,
|
|
||||||
delay: 30,
|
|
||||||
draggable: ".item",
|
|
||||||
filter(event, item) {
|
|
||||||
if (item.dataset.id === "2") {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
onEnd() {
|
|
||||||
const arr = sortable1.toArray();
|
|
||||||
console.log(arr)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const sortable1 = Sortable.create(g1, ops1);
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
|
@ -1,64 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<title>sortable.js dataIdAttr属性例子</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;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tips {
|
|
||||||
border: solid 1px #fff !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
#msg {
|
|
||||||
clear: both;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<div class="box">
|
|
||||||
<div id="g1" class="itxst">
|
|
||||||
<div class="tips">dataIdAttr设置dataId属性</div>
|
|
||||||
<div class="item" data-id="1">item 1</div>
|
|
||||||
<div class="item" data-id="2">item 2</div>
|
|
||||||
<div class="item" data-id="3">item 3</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div id="msg"></div>
|
|
||||||
<script>
|
|
||||||
//第一组
|
|
||||||
const g1 = document.getElementById('g1');
|
|
||||||
const ops1 = {
|
|
||||||
animation: 166,
|
|
||||||
draggable: ".item",
|
|
||||||
dataIdAttr: "data-id",
|
|
||||||
inEnd(evnt) {
|
|
||||||
console.log(evnt)
|
|
||||||
const arr = sortable.toArray()
|
|
||||||
console.log(arr)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const sortable1 = Sortable.create(g1, ops1);
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
36
temp.js
36
temp.js
|
@ -1,16 +1,20 @@
|
||||||
var g1 = document.getElementById('g1');
|
//第一组
|
||||||
var ops1 = {
|
var g1 = document.getElementById('g1');
|
||||||
animation: 1000,
|
var ops1 = {
|
||||||
//指定可以拖动的元素
|
animation: 1000,
|
||||||
draggable: ".item",
|
draggable: ".item",
|
||||||
//************* 拖动后的数据 **********
|
delay: 1000,
|
||||||
dataIdAttr: "data-id",
|
delayOnTouchOnly:true,
|
||||||
//************* 获取拖动结束的数据 **********
|
//拖动结束
|
||||||
onEnd: function (evt) {
|
onEnd: function (evt) {
|
||||||
console.log(evt);
|
//可在浏览器中按F12查看evt对象结构
|
||||||
//获取拖动后的排序
|
console.log(evt);
|
||||||
var arr = sortable1.toArray();
|
//获取拖动后的排序
|
||||||
document.getElementById("msg").innerHTML = "A组排序结果:" + JSON.stringify(arr);
|
var arr = sortable1.toArray();
|
||||||
},
|
document.getElementById("msg").innerHTML = "A组排序结果:" + JSON.stringify(arr);
|
||||||
};
|
},
|
||||||
var sortable1 = Sortable.create(g1, ops1);
|
};
|
||||||
|
function del() {
|
||||||
|
alert("执行了del事件")
|
||||||
|
}
|
||||||
|
var sortable1 = Sortable.create(g1, ops1);
|
Loading…
Reference in New Issue