移动端上下拖动调整顺序效果_jquery、css实现移动端元素拖
动排序
注:本⽂原创,转载请注明出处
1.近期需要实现⼀个选项进⾏拖动排序的页⾯,页⾯如下:
2.JSP页⾯代码:
⽀XX代扣
必要性英语微XX代扣
XXX银⾏代扣
AAA银⾏代扣
CCC银⾏代扣
SSS银⾏代扣
3.css样式代码
body {
网络拓扑结构
background-color: #ffffff; padding: 0;qq靓号注册
margin: 0;
}
.main{
width: 100%;
height: 100%;
box-sizing: border-box;
padding: 0px;
}
.drag-div{
width: 100%;
height:100%;
overflow:auto;
position: absolute;
}
有奖竞猜题目.others{
width: 100%;
height: auto;
background-color: #ddd000; position: relative;
}
.drag-div-elem{
border-left: 1px solid #dddddd; border-right: 1px solid #dddddd; border-bottom:1px solid #dddddd; border-top: 1px solid #dddddd;
width: 100%;
height: 50px;
background-color: #ffffff; position: absolute;
}
.drag-first-elem{
border-top: 1px solid #dddddd;
}
.payway-info{
width: 80%;
height: 100%;
float: left;
padding-left: 15px;
text-align: left;
line-height: 50px;
font-size: 20px;
}
.drag-elem-btn{
width: 20%;
max-width:60px;
height: 48px;
float: right;
padding: 10px;
border: 0px;
}
.
drag-elem-btn-icon{
width: 100%;
height: 100%;
border-left: 0px;
border-right: 0px;
border-top: 4px solid #dddddd; border-bottom:4px solid #dddddd; padding-bottom: 8px;
padding-top: 8px;
background-clip:content-box;
background-color: #dddddd;
}
.show-top{
z-index: 20;
filter:alpha(Opacity=70);
-moz-opacity:0.7;
opacity: 0.7;
box-shadow:#000 0px 5px 6px 3px ;
}
.drag-int-div{
background-color: #dddddd;
}
4.js代码
/**
*
*/
var isdrag = true; //是否移动
var topHeight = $(".others").css("height"); //头部div的⾼度
var topHeightInt = 0;
var elementHeight = $(".drag-div-elem").css("height"); //每⼀个移动元素DIV的⾼度var elementHeightInt = 0;
var halfElementHeightInt = 0;
var startEleCssTopInt;//元素div的起始时的top值
var lastTouchTempY = null;//上⼀次滑动时元素触摸点坐标
面具制作var startTouchY; //起始时的触摸点坐标
var choEleNum = null; //选择的是第⼏个元素
清头var eleMoveDistance = 0; //选择元素相对于其他元素的距离慢性格林巴利
var isNeedMoveEle = true; //其他元素是否需要移动
var theMaxNumberAttr = null; //元素最⼤的number值
凝聚作文600字var theMinNumberAttr = null; //元素最⼩的number值
var theMaxMoveScope = null; //可以移动的最⼤范围 ,最⼩范围为topHeightInt;//开始移动
function dragStart(e) {