隨筆 - 11  文章 - 3  trackbacks - 0
          <2010年1月>
          272829303112
          3456789
          10111213141516
          17181920212223
          24252627282930
          31123456

          常用鏈接

          留言簿

          隨筆檔案

          文章檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主要功能:
          1.拖動
          2.可配置相對位置
          3.平滑移動

          CE.Tween = {
           plcMove : function(o, a, s, e, callback, speed){
            var sTime = +new Date(), p, speed = speed || 100;
            var iTimer = setInterval(function(){
             p = (+new Date() - sTime) / speed;
             if(p >= 1){
              o.style[a] = e + "px";
              callback && callback.call(o);
              o = null;
              return clearInterval(iTimer);
             }
             o.style[a] = s + (e - s) * ((-Math.cos(p * Math.PI) / 2) + 0.5) + "px";
            }, 10);
           }
          };

          CE.Util.Drag 
          = {
              dcount : 
          0,
              dList : {},
              bind : function(c,obj){
                  var _this 
          = CE.Util.Drag;

                  var _d 
          = obj.d || c;

                  
          if(!_d){return;}

                  
          if(!_d.did){

                      _d.did 
          = _this.dcount++;

                      _this.dList[_d.did] 
          = _d;

                      var _x ,_y,_isdown 
          = false,_scape = null,_p = null;

                      _d.style.cursor 
          = "move";

                      var down 
          = function(e){
                          _isdown 
          = true;

                          _p 
          = obj.refer || document.body;

                          _x 
          = e.clientX - _d.offsetLeft; //初始坐標
                          _y = e.clientY - _d.offsetTop;

                          
          if(null == _scape){
                              _scape 
          = document.createElement("div");
                              _p.appendChild(_scape);
                          }

                          _scape.style.border 
          = "1px dotted #06459c";
                          _scape.style.position 
          = "absolute";
                          _scape.style.zIndex 
          = c.style.zIndex + 1 || 1;
                          _scape.style.width 
          = c.style.width;
                          _scape.style.height 
          = c.style.height;
                          _scape.style.left 
          = c.offsetLeft + "px";
                          _scape.style.top 
          = c.offsetTop + "px";

                          c.style.filter 
          = "Alpha(Opacity=60)";
                          c.style.opacity 
          = 0.6;

                          
          if(_scape){
                              CE.Event.addListener(document,
          "mousemove",move);
                              CE.Event.addListener(document,
          "mouseup",up);
                              document.onselectstart 
          = function() {return false};
                              
          if(window.getSelection){ //非ie
                                  window.getSelection().removeAllRanges();
                              }
                          }
                      };
                      var move 
          = function(e){
                          
          if(!_isdown){return};
                          _scape.style.left 
          = e.clientX - _x + "px";
                          _scape.style.top 
          = e.clientY - _y + "px";
                      };
                      var up 
          = function(){
                          _isdown 
          = false;
                          
          if(_scape){
                              
          if(obj.tween){
                                  CE.Tween.plcMove(c,
          "top",parseInt(c.style.top, 10),_scape.offsetTop);
                                  CE.Tween.plcMove(c,
          "left",parseInt(c.style.left, 10),_scape.offsetLeft);
                              }
          else{
                                  c.style.left 
          = _scape.offsetLeft + "px";
                                  c.style.top 
          = _scape.offsetTop + "px";
                              }
                              c.style.filter 
          = "Alpha(Opacity=100)";
                              c.style.opacity 
          = 1;
                              _scape.style.zIndex 
          = c.zIndex - 1 || -1;
                              _p.removeChild(_scape);
                              _p 
          = null;
                              _scape 
          = null;
                              document.onselectstart 
          = function() {return true};
                          }
                      };
                      CE.Event.addListener(_d,
          "mousedown",down);
                  }
          else{
                      
          for(var item in _this.dList){
                          
          if(_d.did === item.did){
                              
          return;
                          }
                      }
                  }
              }
          };
          posted on 2010-01-17 12:16 jacklau 閱讀(189) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 聂拉木县| 万盛区| 夏河县| 荃湾区| 高雄市| 革吉县| 留坝县| 天全县| 武邑县| 泽普县| 长宁县| 普安县| 宁蒗| 大同市| 田林县| 图木舒克市| 辽源市| 建瓯市| 周口市| 靖远县| 抚顺县| 瑞安市| 黑山县| 陵水| 连山| 天全县| 南安市| 宁安市| 云林县| 云南省| 博罗县| 舒城县| 白银市| 莱芜市| 基隆市| 北宁市| 罗源县| 汉中市| 凌源市| 平南县| 化隆|