在拖动div的时候
点击div 然后就可以拖动 但是在拖动的时候很卡 鼠标移动太快 div就会停在那里 不跟着鼠标移动
如果再次点击刚才拖动的div 随意拖动都不会卡 
到底是哪里出了问题呢?
//js代码--------------------------------------------------------------------------
$(document).ready(function() {
  var p1=new Endrag('section-head', 'section','inner-section');
});
function Endrag(source,target,innermove){
  innermove=typeof(innermove)=="object" ? innermove:document.getElementById(innermove);
  var x0=0,y0=0,moveable=false,index=100,NS=(navigator.appName=='Netscape');
  if($('#' + source)){
    //鼠标点击div
    $('#' + source).mousedown(function(e){
      var event_mousedown = e;
      if (e.target.className == '') {
        location.href = e.target.href;
        return;
      }
      everdivheight = $('#' + target).height();
      $('#' + target + ' .progress-indicator').show();
      $('#' + target).css('background','#ddd').css('color','#ddd').css('position','relative');
      everdivhtmlheader = $('#' + target + ' .show-div-h').html();
      everdivhtmlcontent = $('#'+target+ ' .show-div-c').html();
      $('#' + target + ' .show-div-h').html('');
      $('#' + target + ' .show-div-c').html('');
      $('#' + target).css('height', everdivheight);
      e = e ? e : (window.event ? window.event : null);
      if(e.button==(NS)?0 :1)  {
        if(!NS){this.setCapture();}
        x0 = e.pageX ; 
        y0 = e.pageY ; 
        moveable = true; 
      }    }); 
    //拖动;
    var position_top = 0;
    var position_now_top = 0;
    $('#'+source +'-inner').mousemove(function(e){
      e = e ? e : (window.event ? window.event : null); 
      if(moveable){ 
        innermove.style.left = (e.pageX-x0 ) +"px";
        innermove.style.top = (e.pageY-y0 ) +"px";
        if(position_top == 0) {
          position_top = innermove.style.top;
          position_top = parseInt(position_top.replace('px',''));
        }
        position_now_top = innermove.style.top;
        position_now_top = parseInt(position_now_top.replace('px',''));
      }
      position_top = position_now_top;
    });
    //停止拖动; 
    $('#'+source+'-inner').mouseup(function (e){
      if(moveable)  { 
        if(!NS){this.releaseCapture();}
        moveable = false; 
      }
      $('#'+target +' .progress-indicator').animate({left: 0,top: 0},"slow","",function(){
          $(this).hide();
          $('#'+target).css('background','').css('color','').css('position','static');
          $('#'+target+' .show-div-h').append(everdivhtmlheader);
          $('#'+target+' .show-div-c').append(everdivhtmlcontent);      });
    });
  }
}
html代码----------------------------------------------------------------------------------
    <div id="section" class="section moved" >
      <div id="section-head" class="header show-div-h">
        <h2 class='title-other'>简介
        </h2>
      </div>
      <div class="content show-div-c">        <div class="profile-supply">
          <h3>专长</h3>
          <p>          </p>    
        </div>
     </div>
     <div class="progress-indicator" id="inner-section">
      <div id="section-head-inner" class="header">
        <h2 class='title-other'>简介
 
        </h2>
      </div>
      <div class="content">        <div class="profile-supply">
          <h3>专长</h3>
          <p>
  
          </p>    
        </div>
      </div>
     </div>
  </div> <!-- .section -->
---------------------------------------------------------------------------------------
跪求解答!!!!

解决方案 »

  1.   

    火狐浏览器上都卡 点击第一下的时候卡,div不能快速的跟上鼠标 ,div就会在那不动了  然后你再去点那个div(也就是第二次点它) 随便拖动 div都能跟上鼠标
      

  2.   

    我这提供两个效果,都是拖动DIV的,而且很兼容:1、仿iGoogle自定义首页模块拖拽效果(推荐),此效果有记忆功能,可记录以前移动的位置
    http://www.websjy.com/bbs/viewthread.php?tid=42612、javascript实现可以拖动的层示例(层拖动,兼容IE/FF)http://www.websjy.com/bbs/viewthread.php?tid=2665
      

  3.   

    希望这个能给你帮助http://www.cnblogs.com/rubylouvre/archive/2009/09/09/1563342.html