欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

javascript實(shí)現(xiàn)的元素拖動(dòng)函數(shù)宿主為瀏覽器

 更新時(shí)間:2014年07月21日 16:59:36   投稿:whsnow  
這篇文章主要介紹了javascript實(shí)現(xiàn)的元素拖動(dòng),將相應(yīng)的元素對(duì)象的引用傳到函數(shù)中
//宿主為瀏覽器  
//將相應(yīng)的元素對(duì)象的引用傳到函數(shù)中  
function candrag(drager) { 
  drager.onmousedown = function (down) { 
    var offx = drager.offsetLeft 
    var offy = drager.offsetTop; 
    var offxl = down.clientX - offx; 
    var offyl = down.clientY - offy; 
    window.condition = 0;//為window添加了condition屬性,用于解決和click之間的矛盾  
    document.onmousemove = function (move) { 
      drager.style.left = move.clientX - offxl + "px"; 
      drager.style.top = move.clientY - offyl + "px"; 
      drager.style.cursor = "move"; 
      condition = Math.abs(move.clientX - down.clientX) + Math.abs(move.clientY - down.clientY); 
    } 
  } 
  drager.onmouseup = function () { 
    document.onmousemove = null; 
    draggerr.style.cursor = "auto"; 
  } 
} 
/*對(duì)于和click之間的矛盾解決,需要判斷condition 
*例如: 
candrag(dragger); 
d01.onclick = function () { 
  if (!condition) { 
    d01.style.backgroundColor = "red"; 
  } 
} 
*其中,d01為dragger的子元素 
*/ 

相關(guān)文章

最新評(píng)論