复制代码 代码如下:
(function($){
$.fn.lsMovePanel=function(){
var id=this.attr("id");
var X=Y=0;
var offsetX=offsetY=0;//绝对位置
var OldIndex=0;///存储原始索引
var Temp_Li="<li id=\"Temp_Li\" style=\"background-color:#FFFFFF;border-color:#FF023C\"></li>";
var Move_obj;///当前拖动的对象
$("#"+id+" li").each(function(i){
$(this).attr("open","0");
//鼠标点击
$(this).bind("mousedown",function(){
if(event.button==1 || event.button==0){$(this).attr("open","1");}
if($(this).attr("open")=="1"){
$(this).css({
cursor:"move",
opacity:"0.7"
});
X=event.clientX;
Y=event.clientY;
offsetX=$(this).offset().left;
offsetY=$(this).offset().top;
OldIndex=$(this).index();
$(this).css({
position:"absolute",
left:offsetX,
top:offsetY
});
$("#"+id+" li").each(function(i){
if(i==OldIndex){
$(this).after(Temp_Li);
}
})
}
});
//鼠标放开
$(this).bind("mouseup",function(){
if(event.button==1 || event.button==0){$(this).attr("open","0");}
if($(this).attr("open")=="0"){
$("#Temp_Li").before($(this));
$(this).animate({
left:$("#Temp_Li").offset().left,
top:$("#Temp_Li").offset().top,
},300,function(){
$("#Temp_Li").remove();
$(this).css({
cursor:"default",
opacity:"1",
position:"static"
});
});
$("#"+id+" li").each(function(i){
$(this).css({
"border-color":"#666666"
});
});
}
});
//移动
$(this).bind("mousemove",function(){
if($(this).attr("open")=="1"){
var current_X=current_Y=0;
current_X=offsetX+event.clientX-X;
current_Y=offsetY+event.clientY-Y;
$(this).css({
position:"absolute",
left:current_X,
top:current_Y
});
Move_obj=this;
$("#"+id+" li").each(function(i){
if(i!=OldIndex && $(this).attr("id")!="Temp_Li"){
var Deviation=0;
var Max_X=$(this).offset().left+$(this).width()-Deviation;
var Min_X=$(this).offset().left+Deviation;
var Max_Y=$(this).offset().top+$(this).height()-Deviation;
var Min_Y=$(this).offset().top+Deviation;
if((event.clientX < Max_X) && (event.clientY+$(Move_obj).height() > Max_Y) && (event.clientY+$(Move_obj).height() > Min_Y) && (event.clientX > Min_X) && (event.clientY < Max_Y) ){
$(this).css({
"border-color":"#FF7578"
});
//判断覆盖对象索引值在前还是后
if(OldIndex>$(this).index()){
$("#Temp_Li").before($(this));
$("#Temp_Li").remove();
$(this).before(Temp_Li);
}else{
$("#Temp_Li").after($(this));
$("#Temp_Li").remove();
$(this).after(Temp_Li);
}
}else{
$(this).css({
"border-color":"#666666"
});
}
}
})
}
});
});
}
})(jQuery);

调用例子:
复制代码 代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
<title></title>
<style>
#Panel{
width:630px;
height:auto;
padding:0px;
}
#Panel li{
float:left;
list-style:none;
width:300px;
height:100px;
margin:5px;
background-color:#D9F1FF;
border:1px dotted #666666;
text-align:center; position:static;
}
*{
font-size:12px;
}
</style>
</head>
<script src="/UploadFiles/2021-04-02/jquery-1.4.2.min.js"><script src="http://demo.jb51.net/jslib/lsMovePanel.js"><body>
<div style="margin-left:100px;">
<ul id="Panel">
<li style="background-color:#3399FF"></li>
<li style="background-color:#00CCFF"></li>
<li style="background-color:#CC9900"></li>
<li style="background-color:#FF6600"></li>
<li style="background-color:#FFCC99"></li>
</ul>
</div>
<script>
$("#Panel").lsMovePanel();
</script>
</body>
</html>
标签:
jquery,拖动布局

免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
狼山资源网 Copyright www.pvsay.com

评论“基于jquery的拖动布局插件”

暂无“基于jquery的拖动布局插件”评论...

《魔兽世界》大逃杀!60人新游玩模式《强袭风暴》3月21日上线

暴雪近日发布了《魔兽世界》10.2.6 更新内容,新游玩模式《强袭风暴》即将于3月21 日在亚服上线,届时玩家将前往阿拉希高地展开一场 60 人大逃杀对战。

艾泽拉斯的冒险者已经征服了艾泽拉斯的大地及遥远的彼岸。他们在对抗世界上最致命的敌人时展现出过人的手腕,并且成功阻止终结宇宙等级的威胁。当他们在为即将于《魔兽世界》资料片《地心之战》中来袭的萨拉塔斯势力做战斗准备时,他们还需要在熟悉的阿拉希高地面对一个全新的敌人──那就是彼此。在《巨龙崛起》10.2.6 更新的《强袭风暴》中,玩家将会进入一个全新的海盗主题大逃杀式限时活动,其中包含极高的风险和史诗级的奖励。

《强袭风暴》不是普通的战场,作为一个独立于主游戏之外的活动,玩家可以用大逃杀的风格来体验《魔兽世界》,不分职业、不分装备(除了你在赛局中捡到的),光是技巧和战略的强弱之分就能决定出谁才是能坚持到最后的赢家。本次活动将会开放单人和双人模式,玩家在加入海盗主题的预赛大厅区域前,可以从强袭风暴角色画面新增好友。游玩游戏将可以累计名望轨迹,《巨龙崛起》和《魔兽世界:巫妖王之怒 经典版》的玩家都可以获得奖励。