element 的 table使用Sortable.js进行拖拽的时候,禁止某些列的拖拽功能

element 的 table使用Sortable.js进行拖拽的时候,禁止某些列的拖拽功能,第1张

因为element中的table不具备拖拽排序的功能,所以有时候会用到Sortablejs去实现拖拽的功能。具体的使用方法可以参考以下 >pc上的web页面鼠标会产生onmousedown、onmouseup、onmouseout、onmouseover、onmousemove的事件,但是在移动终端如iphone、ipod Touch、ipad上的web页面触屏时会产生ontouchstart、ontouchmove、ontouchend、ontouchcancel事件,分别对应了触屏开始、拖拽及完成触屏事件和取消。

<script type="text/javascript" src=">以下直接可以运行。
如果DIV在ID为area的div中,即可拖拽。我在Drag函数里做了对父div的判断。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 10 Strict//EN" ">ondragstart 事件:当拖拽元素开始被拖拽的时候触发的事件,此事件作用在被拖曳元素上
ondragenter 事件:当拖曳元素进入目标元素的时候触发的事件,此事件作用在目标元素上
ondragover 事件:拖拽元素在目标元素上移动的时候触发的事件,此事件作用在目标元素上
ondrop 事件:被拖拽的元素在目标元素上同时鼠标放开触发的事件,此事件作用在目标元素上
ondragend 事件:当拖拽完成后触发的事件,此事件作用在被拖曳元素上~

没搞懂你objWin是什么意思,全部改成td后才能成功移动,感觉并不卡。
<div id="td"></div>
<script>
tdonmousedown = function () {//鼠标按下
thisstylecursor = "move"; //设置鼠标样式
var d = document;
a = windowevent; //按下时创建一个事件
var x = aclientX - documentbodyscrollLeft - tdoffsetLeft; //x=鼠标相对于网页的x坐标-网页被卷去的宽-待移动对象的左外边距
var y = aclientY - documentbodyscrollTop - tdoffsetTop; //y=鼠标相对于网页的y左边-网页被卷去的高-待移动对象的左上边距
donmousemove = function () {//鼠标移动
a = windowevent; //移动时创建一个事件
tdstyleleft = aclientX + documentbodyscrollLeft - x;
tdstyletop = aclientY + documentbodyscrollTop - y;
};
donmouseup = function () {//鼠标放开
tdstylecursor = "normal"; //设置放开的样式
documentonmousemove = null;
documentonmouseup = null;
};
};
</script>

mousedown的时候设置鼠标的样式,mouseup还原不就行了:
$(function(){
$("#area_b")mousedown(function(e1){
$("#cont")css("cursor", "move");
var area_a_h = $("#area_a")height(),
area_c_h = $("#area_c")height();
$(document)bind("mousemove",function(e2){
var curr = e2pageY -e1pageY;
$("#area_a")height(area_a_h + curr);
$("#area_c")height(area_c_h - curr);
})mouseup(function(){
$("#cont")css("cursor", "default");
$(document)unbind("mousemove");
})
})
})


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/dianzi/13327025.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-07-15
下一篇 2023-07-15

发表评论

登录后才能评论

评论列表(0条)

保存