日韩天天综合网_野战两个奶头被亲到高潮_亚洲日韩欧美精品综合_av女人天堂污污污_视频一区**字幕无弹窗_国产亚洲欧美小视频_国内性爱精品在线免费视频_国产一级电影在线播放_日韩欧美内地福利_亚洲一二三不卡片区
模板無憂
網(wǎng)頁特效
每日更新
|
TOP排行榜
|
Tag標(biāo)簽
|
充值
無憂首頁
網(wǎng)頁模板
程序模板
建站教程
視頻教程
網(wǎng)頁特效
圖標(biāo)素材
字體下載
站長工具
站長問答
網(wǎng)頁特效
菜單導(dǎo)航
圖片特效
文本鏈接
層和布局
頁面背景
表單按鈕
日期時間
計算轉(zhuǎn)換
鍵盤鼠標(biāo)
瀏覽器
游戲娛樂
綜合其它
常用代碼
jQuery特效
Prototype
Ajax/JavaScript
ExtJS
CSS特效
在線編輯器
Mootools
HTML
JS廣告代碼合集
站長工具
站長常用軟件
網(wǎng)站綜合查詢
Alexa排名查詢
Google PR查詢
域名Whois查詢
網(wǎng)站收錄查詢
友情鏈接查詢
CSS2中文手冊
CSS精簡優(yōu)化工具
網(wǎng)頁特效代碼
模板無憂
>
網(wǎng)頁特效
>
層和布局特效代碼
>
收藏
分享
查看評論
層和布局
演示
Js層拖動/拖放代碼_層和布局特效
查看演示效果
特效Tag:
層拖動
添加
這個很不錯,利用JS拖動一個DIV層,代碼很有修改,和以往的拖放都有點不一樣,研究一下吧。
<!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" mrc="text/html; charset=gb2312" /> <title>拖放效果_mb5u.com</title> </head> <body> <script> var isIE = (document.all) ? true : false; // Demo by / var $ = function (id) { return "string" == typeof id ? document.getElementById(id) : id; }; var Class = { create: function() { return function() { this.initialize.apply(this, arguments); } } } var Extend = function(destination, source) { for (var property in source) { destination[property] = source[property]; } } var Bind = function(object, fun) { return function() { return fun.apply(object, arguments); } } var BindAsEventListener = function(object, fun) { return function(event) { return fun.call(object, (event || window.event)); } } var CurrentStyle = function(element){ return element.currentStyle || document.defaultView.getComputedStyle(element, null); } // Demo by / function addEventHandler(oTarget, sEventType, fnHandler) { if (oTarget.addEventListener) { oTarget.addEventListener(sEventType, fnHandler, false); } else if (oTarget.attachEvent) { oTarget.attachEvent("on" + sEventType, fnHandler); } else { oTarget["on" + sEventType] = fnHandler; } }; function removeEventHandler(oTarget, sEventType, fnHandler) { if (oTarget.removeEventListener) { oTarget.removeEventListener(sEventType, fnHandler, false); } else if (oTarget.detachEvent) { oTarget.detachEvent("on" + sEventType, fnHandler); } else { oTarget["on" + sEventType] = null; } }; //拖放程序 var Drag = Class.create(); Drag.prototype = { //拖放對象 initialize: function(drag, options) { this.Drag = $(drag);//拖放對象 this._x = this._y = 0;//記錄鼠標(biāo)相對拖放對象的位置 this._marginLeft = this._marginTop = 0;//記錄margin //事件對象(用于綁定移除事件) this._fM = BindAsEventListener(this, this.Move); this._fS = Bind(this, this.Stop); this.SetOptions(options); // Demo by / this.Limit = !!this.options.Limit; this.mxLeft = parseInt(this.options.mxLeft); this.mxRight = parseInt(this.options.mxRight); this.mxTop = parseInt(this.options.mxTop); this.mxBottom = parseInt(this.options.mxBottom); this.LockX = !!this.options.LockX; this.LockY = !!this.options.LockY; this.Lock = !!this.options.Lock; this.onStart = this.options.onStart; this.onMove = this.options.onMove; this.onStop = this.options.onStop; this._Handle = $(this.options.Handle) || this.Drag; this._mxContainer = $(this.options.mxContainer) || null; this.Drag.style.position = "absolute"; //透明 if(isIE && !!this.options.Transparent){ //填充拖放對象 with(this._Handle.appendChild(document.createElement("div")).style){ width = height = "100%"; backgroundColor = "#fff"; filter = "alpha(opacity:0)"; fontSize = 0; } } //修正范圍 this.Repair(); addEventHandler(this._Handle, "mousedown", BindAsEventListener(this, this.Start)); }, //設(shè)置默認(rèn)屬性 SetOptions: function(options) { this.options = {//默認(rèn)值 Handle: "",//設(shè)置觸發(fā)對象(不設(shè)置則使用拖放對象) Limit: false,//是否設(shè)置范圍限制(為true時下面參數(shù)有用,可以是負(fù)數(shù)) mxLeft: 0,//左邊限制 mxRight: 9999,//右邊限制 mxTop: 0,//上邊限制 mxBottom: 9999,//下邊限制 mxContainer: "",//指定限制在容器內(nèi) LockX: false,//是否鎖定水平方向拖放 LockY: false,//是否鎖定垂直方向拖放 Lock: false,//是否鎖定 Transparent: false,//是否透明 onStart: function(){},//開始移動時執(zhí)行 onMove: function(){},//移動時執(zhí)行 onStop: function(){}//結(jié)束移動時執(zhí)行 }; Extend(this.options, options || {}); }, //準(zhǔn)備拖動 Start: function(oEvent) { if(this.Lock){ return; } this.Repair(); //記錄鼠標(biāo)相對拖放對象的位置 this._x = oEvent.clientX - this.Drag.offsetLeft; this._y = oEvent.clientY - this.Drag.offsetTop; //記錄margin this._marginLeft = parseInt(CurrentStyle(this.Drag).marginLeft) || 0; this._marginTop = parseInt(CurrentStyle(this.Drag).marginTop) || 0; //mousemove時移動 mouseup時停止 addEventHandler(document, "mousemove", this._fM); addEventHandler(document, "mouseup", this._fS); if(isIE){ //焦點丟失 addEventHandler(this._Handle, "losecapture", this._fS); //設(shè)置鼠標(biāo)捕獲 this._Handle.setCapture(); }else{ //焦點丟失 addEventHandler(window, "blur", this._fS); //阻止默認(rèn)動作 oEvent.preventDefault(); }; //附加程序 this.onStart(); }, //修正范圍 Repair: function() { if(this.Limit){ //修正錯誤范圍參數(shù) this.mxRight = Math.max(this.mxRight, this.mxLeft + this.Drag.offsetWidth); this.mxBottom = Math.max(this.mxBottom, this.mxTop + this.Drag.offsetHeight); //如果有容器必須設(shè)置position為relative或absolute來相對或絕對定位,并在獲取offset之前設(shè)置 !this._mxContainer || CurrentStyle(this._mxContainer).position == "relative" || CurrentStyle(this._mxContainer).position == "absolute" || (this._mxContainer.style.position = "relative"); } }, //拖動 Move: function(oEvent) { //判斷是否鎖定 if(this.Lock){ this.Stop(); return; }; //清除選擇 window.getSelection ? window.getSelection().removeAllRanges() : document.selection.empty(); //設(shè)置移動參數(shù) var iLeft = oEvent.clientX - this._x, iTop = oEvent.clientY - this._y; //設(shè)置范圍限制 if(this.Limit){ //設(shè)置范圍參數(shù) var mxLeft = this.mxLeft, mxRight = this.mxRight, mxTop = this.mxTop, mxBottom = this.mxBottom; //如果設(shè)置了容器,再修正范圍參數(shù) if(!!this._mxContainer){ mxLeft = Math.max(mxLeft, 0); mxTop = Math.max(mxTop, 0); mxRight = Math.min(mxRight, this._mxContainer.clientWidth); mxBottom = Math.min(mxBottom, this._mxContainer.clientHeight); }; //修正移動參數(shù) iLeft = Math.max(Math.min(iLeft, mxRight - this.Drag.offsetWidth), mxLeft); iTop = Math.max(Math.min(iTop, mxBottom - this.Drag.offsetHeight), mxTop); } //設(shè)置位置,并修正margin if(!this.LockX){ this.Drag.style.left = iLeft - this._marginLeft + "px"; } if(!this.LockY){ this.Drag.style.top = iTop - this._marginTop + "px"; } //附加程序 this.onMove(); }, //停止拖動 Stop: function() { //移除事件 removeEventHandler(document, "mousemove", this._fM); removeEventHandler(document, "mouseup", this._fS); if(isIE){ removeEventHandler(this._Handle, "losecapture", this._fS); this._Handle.releaseCapture(); }else{ removeEventHandler(window, "blur", this._fS); }; //附加程序 this.onStop(); } }; </script> <style> #idContainer{ border:10px solid #990000; width:600px; height:300px;} #idDrag{ border:5px solid #C4E3FD; background:#C4E3FD; width:50px; height:50px; top:50px; left:50px;} #idHandle{cursor:move; height:25px; background:#0000FF; overflow:hidden;} </style> <div id="idContainer"> <div id="idDrag"><div id="idHandle"></div></div> </div> <input id="idReset" type="button" value="復(fù)位" /> <input id="idLock" type="button" value="鎖定" /> <input id="idLockX" type="button" value="鎖定水平" /> <input id="idLockY" type="button" value="鎖定垂直" /> <input id="idLimit" type="button" value="范圍鎖定" /> <input id="idLimitOff" type="button" value="取消范圍鎖定" /> <br />拖放狀態(tài):<span id="idShow">未開始</span> <script> var drag = new Drag("idDrag", { mxContainer: "idContainer", Handle: "idHandle", Limit: true, onStart: function(){ $("idShow").innerHTML = "開始拖放"; }, onMove: function(){ $("idShow").innerHTML = "left:"+this.Drag.offsetLeft+";top:"+this.Drag.offsetTop; }, onStop: function(){ $("idShow").innerHTML = "結(jié)束拖放"; } }); $("idReset").onclick = function(){ drag.Limit = true; drag.mxLeft = drag.mxTop = 0; drag.mxRight = drag.mxBottom = 9999; drag.LockX = drag.LockY = drag.Lock = false; } $("idLock").onclick = function(){ drag.Lock = true; } $("idLockX").onclick = function(){ drag.LockX = true; } $("idLockY").onclick = function(){ drag.LockY = true; } $("idLimit").onclick = function(){ drag.mxRight = drag.mxBottom = 200;drag.Limit = true; } $("idLimitOff").onclick = function(){ drag.Limit = false; } </script> </body> </html>
所屬頻道:
層和布局特效
/
更新時間:2012-12-07
[收藏]
[報錯]
[返回列表]
相關(guān)
層和布局特效
:
表格內(nèi)容排序sortTable
行變成列,列變成行
文本輸入限制
拆分單元格
控制表格內(nèi)的滾動條
顏色交替的表格
JS計算里面有多少個
極酷的表格
會動的表格
可拖動單元格
變色表格
訪問表格的每個TD
層和布局特效Rss訂閱
特效代碼搜索
層和布局特效推薦
表格透明,可自定義透明度
CSS實現(xiàn)左右、上下不封閉邊框的表格
寬度為一象素的表格
緩沖展開/關(guān)閉層
最精簡的JavaScript鼠標(biāo)拖動代碼
JavaScript仿關(guān)機(jī)界面
一款很酷的li列表美化實例
CSS使用LI實現(xiàn)2組4列的文章列表并垂直對齊
鼠標(biāo)拖拉按比例縮放的JavaScript
CSS中1px虛線邊框的方法
猜你也喜歡看這些
鼠標(biāo)滑向文字改變網(wǎng)頁背景色
QQ式的導(dǎo)航(new)
滾動條顏色生成器
CSS定義背景居中的方法
清爽配色15套
頁面載入時的進(jìn)度條效果的實現(xiàn)
鼠標(biāo)使鏈接變色:鼠標(biāo)放到鏈接上,每放一次都會出現(xiàn)不同的背景色
無縫滾動
頁面背景漸變
手動調(diào)節(jié)背景色:背景色能用按鈕進(jìn)行手動調(diào)節(jié)
相關(guān)鏈接:
復(fù)制本頁鏈接
|
搜索Js層拖動/拖放代碼
特效說明:
層和布局模板
-
Js層拖動/拖放代碼
。