Compare commits
5 Commits
e8fc5a4b44
...
2bd87cee7b
Author | SHA1 | Date |
---|---|---|
|
2bd87cee7b | |
|
e04e77f383 | |
|
6d928642da | |
|
505545aa88 | |
|
44bac47978 |
|
@ -0,0 +1,39 @@
|
|||
// @see: https://www.prettier.cn
|
||||
|
||||
module.exports = {
|
||||
// 超过最大值换行
|
||||
printWidth: 130,
|
||||
// 缩进字节数
|
||||
tabWidth: 0,
|
||||
// 使用制表符而不是空格缩进行
|
||||
useTabs: true,
|
||||
// 结尾不用分号(true有,false没有)
|
||||
semi: true,
|
||||
// 使用单引号(true单引号,false双引号)
|
||||
singleQuote: true,
|
||||
// 更改引用对象属性的时间 可选值"<as-needed|consistent|preserve>"
|
||||
quoteProps: 'as-needed',
|
||||
// 在对象,数组括号与文字之间加空格 "{ foo: bar }"
|
||||
bracketSpacing: true,
|
||||
// 多行时尽可能打印尾随逗号。(例如,单行数组永远不会出现逗号结尾。) 可选值"<none|es5|all>",默认none
|
||||
trailingComma: 'all',
|
||||
// 在JSX中使用单引号而不是双引号
|
||||
jsxSingleQuote: true,
|
||||
// (x) => {} 箭头函数参数只有一个时是否要有小括号。avoid:省略括号 ,always:不省略括号
|
||||
arrowParens: 'avoid',
|
||||
// 如果文件顶部已经有一个 doclock,这个选项将新建一行注释,并打上@format标记。
|
||||
insertPragma: false,
|
||||
// 指定要使用的解析器,不需要写文件开头的 @prettier
|
||||
requirePragma: false,
|
||||
// 默认值。因为使用了一些折行敏感型的渲染器(如GitHub comment)而按照markdown文本样式进行折行
|
||||
proseWrap: 'preserve',
|
||||
// 在html中空格是否是敏感的 "css" - 遵守CSS显示属性的默认值, "strict" - 空格被认为是敏感的 ,"ignore" - 空格被认为是不敏感的
|
||||
htmlWhitespaceSensitivity: 'css',
|
||||
// 换行符使用 lf 结尾是 可选值"<auto|lf|crlf|cr>"
|
||||
endOfLine: 'auto',
|
||||
// 这两个选项可用于格式化以给定字符偏移量(分别包括和不包括)开始和结束的代码
|
||||
rangeStart: 0,
|
||||
rangeEnd: Infinity,
|
||||
|
||||
vueIndentScriptAndStyle: false, // Vue文件脚本和样式标签缩进
|
||||
};
|
|
@ -1,11 +1,12 @@
|
|||
<!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">
|
||||
<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 {
|
||||
|
@ -49,16 +50,15 @@
|
|||
const g1 = document.getElementById('g1');
|
||||
const ops1 = {
|
||||
animation: 166,
|
||||
draggable: ".item",
|
||||
dataIdAttr: "data-id",
|
||||
draggable: '.item',
|
||||
dataIdAttr: 'data-id',
|
||||
inEnd(evnt) {
|
||||
console.log(evnt)
|
||||
const arr = sortable.toArray()
|
||||
console.log(arr)
|
||||
}
|
||||
console.log(evnt);
|
||||
const arr = sortable.toArray();
|
||||
console.log(arr);
|
||||
},
|
||||
};
|
||||
const sortable1 = Sortable.create(g1, ops1);
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -0,0 +1,62 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>sortable.js ghostClass属性例子</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;
|
||||
width: 80%;
|
||||
float: left;
|
||||
margin-right: 10px;
|
||||
}
|
||||
.itxst div {
|
||||
padding: 6px;
|
||||
border: solid 1px #eee;
|
||||
margin-bottom: 10px;
|
||||
cursor: move;
|
||||
}
|
||||
|
||||
#msg {
|
||||
clear: both;
|
||||
width: 100%;
|
||||
}
|
||||
.ghost {
|
||||
background-color: #6fc77d;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="box">
|
||||
<div id="g1" class="itxst">
|
||||
<div>ghostClass 停靠位置样式 太多下面元素看看</div>
|
||||
<div class="item" data-no="1">item 1</div>
|
||||
<div class="item" data-no="2">item 2</div>
|
||||
<div class="item" data-no="3">item 3</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="msg">["1","2","3"]</div>
|
||||
<script>
|
||||
const g1 = document.getElementById('g1');
|
||||
const msg = document.getElementById('msg');
|
||||
|
||||
const ops = {
|
||||
animation: 166,
|
||||
draggable: '.item',
|
||||
dataIdAttr: 'data-no',
|
||||
ghostClass: 'ghost',
|
||||
onEnd() {
|
||||
const arr = sortable.toArray();
|
||||
msg.innerHTML = JSON.stringify(arr);
|
||||
},
|
||||
};
|
||||
|
||||
const sortable = Sortable.create(g1, ops);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,51 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>sortable.js draggable属性例子</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;
|
||||
width: 80%;
|
||||
}
|
||||
|
||||
#itxst div {
|
||||
padding: 6px;
|
||||
background-color: #fdfdfd;
|
||||
border: solid 1px #eee;
|
||||
margin-bottom: 10px;
|
||||
cursor: move;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="itxst">
|
||||
<div class="item" data-id="1">item 1</div>
|
||||
<div data-id="2">item 2(此元素未设置class="item" 所以无法拖动)</div>
|
||||
<div class="item" data-id="3">item 3</div>
|
||||
</div>
|
||||
<script>
|
||||
//获取对象
|
||||
var el = document.getElementById('itxst');
|
||||
//设置配置
|
||||
var ops = {
|
||||
animation: 1000,
|
||||
draggable: '.item',
|
||||
//拖动结束
|
||||
onEnd: function (evt) {
|
||||
console.log(evt);
|
||||
//获取拖动后的排序
|
||||
var arr = sortable.toArray();
|
||||
alert(JSON.stringify(arr));
|
||||
},
|
||||
};
|
||||
//初始化
|
||||
var sortable = Sortable.create(el, ops);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,80 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>sortable.js dragClass属性例子</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%;
|
||||
}
|
||||
.tips {
|
||||
border: solid 1px #fff !important;
|
||||
}
|
||||
.ghost {
|
||||
background-color: red !important;
|
||||
}
|
||||
.drag {
|
||||
background: #000 !important;
|
||||
background-image: linear-gradient(#333, #999) !important;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="box">
|
||||
<div id="g1" class="itxst">
|
||||
<div class="tips">dragClass 拖动对象的样式</div>
|
||||
<div class="item" data-no="1">item 1</div>
|
||||
<div class="item" data-no="2">item 2</div>
|
||||
<div class="item" data-no="3">item 3</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="msg"></div>
|
||||
<script>
|
||||
// 通过dragClass属性设置拖拽对象移动样式
|
||||
// 需要注意的是css可能需要!important属性进行覆盖同时设置
|
||||
// forceFallback: true禁用html5原生拖拽。
|
||||
const g1 = document.getElementById('g1');
|
||||
const msg = document.getElementById('msg');
|
||||
const ops = {
|
||||
// 动画时间
|
||||
animation: 166,
|
||||
// 拖动的元素
|
||||
draggable: '.item',
|
||||
// 拖动后的数据
|
||||
dataIdAttr: 'data-no',
|
||||
// 停靠位置样式
|
||||
ghostClass: 'ghost',
|
||||
// *********拖动对象的样式
|
||||
dragClass: 'drag',
|
||||
// *********禁用h5原生行为拖拽
|
||||
focusFallback: true,
|
||||
onEnd(event) {
|
||||
console.log(event);
|
||||
const arr = sortable.toArray();
|
||||
msg.innerHTML = JSON.stringify(arr);
|
||||
},
|
||||
};
|
||||
|
||||
const storable = Sortable.create(g1, ops);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,88 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>sortable.js chosenClass属性例子</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;
|
||||
}
|
||||
|
||||
.itxst .innner {
|
||||
padding: 6px;
|
||||
background-color: #fdfdfd;
|
||||
border: solid 1px #eee;
|
||||
margin-bottom: 10px;
|
||||
cursor: move;
|
||||
}
|
||||
|
||||
#msg {
|
||||
clear: both;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.ghost {
|
||||
background-color: red !important;
|
||||
}
|
||||
|
||||
.chosen {
|
||||
border: solid 2px #3089dc !important;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="box">
|
||||
<div id="g1" class="itxst">
|
||||
<div>鼠标点击按住下面的 item 2对象1秒后再拖拽</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>
|
||||
// sortable.js chosenClass 选中拖拽对象的样式
|
||||
// 当设置了delay延迟属性就很容易理解这个属性了
|
||||
// 比如delay延迟1秒当鼠标按住1秒后
|
||||
// 才会添加chosenClass样式到选中的对象。
|
||||
const g1 = document.getElementById('g1');
|
||||
const msg = document.getElementById('msg');
|
||||
const ops = {
|
||||
animation: 166,
|
||||
delay: 166,
|
||||
draggable: '.item',
|
||||
// 停靠样式
|
||||
ghostClass: 'ghost',
|
||||
// ******* 选中样式 *******
|
||||
chosenClass: 'chosen',
|
||||
// 禁用html5原生拖拽行为
|
||||
focusFallback: true,
|
||||
group: { name: 'bunny', pull: true, pull: 'clone' },
|
||||
// 拖动结束
|
||||
onEnd(event) {
|
||||
console.log(event);
|
||||
const arr = sortable.toArray();
|
||||
msg.innerHTML = JSON.stringify(arr);
|
||||
},
|
||||
};
|
||||
|
||||
const sortable = Sortable.create(g1, ops);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
17
temp.js
17
temp.js
|
@ -1,16 +1,21 @@
|
|||
var g1 = document.getElementById('g1');
|
||||
var ops1 = {
|
||||
animation: 1000,
|
||||
//指定可以拖动的元素
|
||||
draggable: ".item",
|
||||
//************* 拖动后的数据 **********
|
||||
dataIdAttr: "data-id",
|
||||
//************* 获取拖动结束的数据 **********
|
||||
delay: 1000,
|
||||
draggable: '.item',
|
||||
//停靠位置样式
|
||||
ghostClass: 'ghost',
|
||||
//************* 选中样式 ***********
|
||||
chosenClass: 'chosen',
|
||||
//禁用html5原生拖拽行为
|
||||
forceFallback: true,
|
||||
group: { name: 'itxst.com', pull: true, put: true },
|
||||
//拖动结束
|
||||
onEnd: function (evt) {
|
||||
console.log(evt);
|
||||
//获取拖动后的排序
|
||||
var arr = sortable1.toArray();
|
||||
document.getElementById("msg").innerHTML = "A组排序结果:" + JSON.stringify(arr);
|
||||
document.getElementById('msg').innerHTML = 'A组排序结果:' + JSON.stringify(arr);
|
||||
},
|
||||
};
|
||||
var sortable1 = Sortable.create(g1, ops1);
|
Loading…
Reference in New Issue