对google个性主页的拖拽效果的js的完整注释[转]

2019-06-02 23:22:44丽君

         // 自己已经浮动了,所以不计算自己的 
         if  (ele  ==   this ) {
             continue ;
        }
         // 如果计算失败继续循环 
         if  (isNaN(distance)) {
             continue ;
        }
         // 如果更小,记录下这个距离,并将它作为found 
         if  (distance  <  max_distance) {
            max_distance  =  distance;
            found  =  ele;
        }
    }
     // 准备让灰框落脚 
     var  _ghostElement  =  getGhostElement();
     // 如果找到了另外的落脚点 
     if  (found  !=   null   &&  _ghostElement.nextSibling  !=  found.elm) {
         // 找到落脚点就先把灰框插进去,这就是我们看到的那个灰框停靠的特效,有点像吸附的感觉,哈哈 
        found.elm.parentNode.insertBefore(_ghostElement, found.elm);
         if  (Util.isOpera) {
             // Opera的现实问题,要隐藏/显示后才能刷新出变化 
            document.body.style.display  =   " none " ;
            document.body.style.display  =   "" ;
        }
    }
};
// 拖拽完毕 
function  end_Drag() {
     // 拖拽完毕后执行后面的钩子,执行after_Drag(),如果布局发生了变动了就记录到远程服务器,保存你拖拽后新的布局顺序 
     if  ( this ._afterDrag()) {