<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 97,  comments - 93,  trackbacks - 0
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>拖拽Demo</title>
    <style type="text/CSS">
    body

    {

        margin:0px;

    }

     

    #aim

    {

        position:absolute;

        width:200px;

        height:30px;

        border:1px solid #666666;

        background-color:#FFCCCC;

    }

     

    #sourceLayer, #cloneLayer

    {

        position:absolute;

        width:300px;

        height:50px;

        border:1px solid #666666;

        background-color:#CCCCCC;

        cursor:move;

    }

     

    .docked

    {

        display:none;

        filter:alpha(opacity=100);

    }

     

    .actived

    {

        display:block;

        filter:alpha(opacity=70);

    }

    </style>

    </head>

     

    <body >

     

    <div id="aim">locate</div>

    <div id="sourceLayer" unselectable="off"><img src="http://www.baidu.com/img/logo.gif" alt="Drag Demo">Source of the demo</div>

    <div id="cloneLayer" class="docked" unselectable="off"></div>


    <script type="text/javascript" language="javascript">


    var aim;

    var sourceLayer;

    var cloneLayer;

    var aimX;

    var aimY;

    var orgnX;

    var orgnY;

    var draging = false;

    var offsetX = 0;    

    var offsetY = 0;    

    var back;        

    var thisX ;        

    var thisY ;        

    var time ;

    var stepX ;        

    var stepY ;       



     

    function getLayer(inAim,inSource,inClone)

    {

        aim = document.getElementById(inAim);

        sourceLayer = document.getElementById(inSource);

        cloneLayer = document.getElementById(inClone);

    }

     

    function initDrag(initAimX,initAimY,initOrgnX,initOrgnY)

    {

        aimX = initAimX;

        aimY = initAimY;

        orgnX = initOrgnX;

        orgnY = initOrgnY;

        aim.style.pixelLeft = aimX;

        aim.style.pixelTop = aimY;

        sourceLayer.style.pixelLeft = orgnX;

        sourceLayer.style.pixelTop = orgnY;

        cloneLayer.style.pixelLeft = orgnX;

        cloneLayer.style.pixelTop = orgnY;

    }


    function BeforeDrag()

    {

        if (event.button != 1)

        {

            return;

        }

        cloneLayer.innerHTML = sourceLayer.innerHTML; 容

        offsetX = document.body.scrollLeft + event.clientX - sourceLayer.style.pixelLeft;

        offsetY = document.body.scrollTop + event.clientY - sourceLayer.style.pixelTop;

        cloneLayer.className = "actived";

        draging = true;

    }



    function OnDrag()

    {

        if(!draging)

        {

            return;

        }

        event.returnValue = false;

        cloneLayer.style.pixelLeft = document.body.scrollLeft + event.clientX - offsetX;

        cloneLayer.style.pixelTop = document.body.scrollTop + event.clientY - offsetY;

    }

    function EndDrag()

    {

        if (event.button != 1)

        {

            return;

        }

        draging = false;

     

        if (event.clientX >= aim.style.pixelLeft && event.clientX <= (aim.style.pixelLeft + aim.offsetWidth) &&

            event.clientY >= aim.style.pixelTop && event.clientY <= (aim.style.pixelTop + aim.offsetHeight))

        {


            sourceLayer.style.pixelLeft = aim.style.pixelLeft;

            sourceLayer.style.pixelTop = aim.style.pixelTop;

             cloneLayer.className = "docked";



        }

        else

        {

         thisX = cloneLayer.style.pixelLeft;

         thisY = cloneLayer.style.pixelTop;

         offSetX = Math.abs(thisX - orgnX);

         offSetY = Math.abs(thisY - orgnY);

         time = 500;

         stepX = Math.floor((offSetX/time)*20);

         stepY = Math.floor((offSetY/time)*20);

         if(stepX == 0)

             stepX = 2;

         if(stepY == 0)

             stepY = 2;

         moveStart();

        }   

    }

     

     

    function moveStart()

    {

         back = setInterval("MoveLayer();",15);

    }

     

    function MoveLayer()

    {


         if(cloneLayer.style.pixelLeft <= orgnX && cloneLayer.style.pixelTop <= orgnY)

         {

             cloneLayer.style.pixelLeft += stepX;

             cloneLayer.style.pixelTop += stepY;


             if(cloneLayer.style.pixelLeft > orgnX)

             {

                  stepX = 1;

             }

             if(cloneLayer.style.pixelTop > orgnY)

             {

                  stepY = 1;

             }

             //if the coordinate of X Y  are  same

             if(cloneLayer.style.pixelLeft == orgnX)

             {

                  stepX = 0;

             }

             if(cloneLayer.style.pixelTop == orgnY)

             {

                  stepY = 0;

             }

             if(cloneLayer.style.pixelLeft == orgnX && cloneLayer.style.pixelTop == orgnY)

             {

                  EndMove();

             }

         }

        

         //locate to the downleft of the object

         else if(cloneLayer.style.pixelLeft <= orgnX && cloneLayer.style.pixelTop >= orgnY)

         {

             cloneLayer.style.pixelLeft += stepX;

             cloneLayer.style.pixelTop -= stepY;

             if(cloneLayer.style.pixelLeft > orgnX)

             {

                  stepX = 1;

             }

             if(cloneLayer.style.pixelTop < orgnY)

             {

                  stepY = 1;

             }

             if(cloneLayer.style.pixelLeft == orgnX)

             {

                  stepX = 0;

             }

             if(cloneLayer.style.pixelTop == orgnY)

             {

                  stepY = 0;

             }

             if(cloneLayer.style.pixelLeft == orgnX && cloneLayer.style.pixelTop == orgnY)

             {

                  EndMove();

             }

         }



         else if(cloneLayer.style.pixelLeft >= orgnX && cloneLayer.style.pixelTop <= orgnY)

         {

             cloneLayer.style.pixelLeft -= stepX;

             cloneLayer.style.pixelTop += stepY;

             if(cloneLayer.style.pixelLeft < orgnX)

             {

                  stepX = 1;

             }

             if(cloneLayer.style.pixelTop > orgnY)

             {

                  stepY = 1;

             }

             if(cloneLayer.style.pixelLeft == orgnX)

             {

                  stepX = 0;

             }

             if(cloneLayer.style.pixelTop == orgnY)

             {

                  stepY = 0;

             }

             if(cloneLayer.style.pixelLeft == orgnX && cloneLayer.style.pixelTop == orgnY)

             {

                  EndMove();

             }

         }

        

         //locate to the right of the object

         else if(cloneLayer.style.pixelLeft >= orgnX && cloneLayer.style.pixelTop >= orgnY)

         {

             cloneLayer.style.pixelLeft -= stepX;

             cloneLayer.style.pixelTop -= stepY;

             if(cloneLayer.style.pixelLeft < orgnX)

             {

                  stepX = 1;

             }

             if(cloneLayer.style.pixelTop < orgnY)

             {

                  stepY = 1;

             }

             if(cloneLayer.style.pixelLeft == orgnX)

             {

                  stepX = 0;

             }

             if(cloneLayer.style.pixelTop == orgnY)

             {

                  stepY = 0;

             }

             if(cloneLayer.style.pixelLeft == orgnX && cloneLayer.style.pixelTop == orgnY)

             {

                  EndMove();

             }

         }

        

         //to the design

         else

         {

             EndMove();

         }

    }

     

    //stop and then back to the state ()carton

    function EndMove()

    {

             sourceLayer.style.pixelLeft = orgnX;

             sourceLayer.style.pixelTop = orgnY;

             cloneLayer.style.pixelLeft = orgnX;

             cloneLayer.style.pixelTop = orgnY;

             cloneLayer.className = "docked";

             clearInterval(back);

    }

     

    //Main function of this demo

    function startDraging(inAim,inSource,inClone,initAimX,initAimY,initOrgnX,initOrgnY)

    {

        getLayer(inAim,inSource,inClone)

        initDrag(initAimX,initAimY,initOrgnX,initOrgnY);

        sourceLayer.onmousedown = BeforeDrag;

        document.onmousemove = OnDrag; //if we use cloneLayer,then the content will be draged ,and well a bug

        cloneLayer.onmouseup = EndDrag;   

    }

     

    //transfer

    startDraging("aim","sourceLayer","cloneLayer",600,500,50,50);

    //-->

    </script>

    </body>

    </html>
    posted on 2007-01-29 14:42 wqwqwqwqwq 閱讀(633) 評論(0)  編輯  收藏 所屬分類: Simple Java
    <2007年1月>
    31123456
    78910111213
    14151617181920
    21222324252627
    28293031123
    45678910




    常用鏈接

    留言簿(10)

    隨筆分類(95)

    隨筆檔案(97)

    文章檔案(10)

    相冊

    J2ME技術網站

    java技術相關

    mess

    搜索

    •  

    最新評論

    閱讀排行榜

    校園夢網網絡電話,中國最優秀的網絡電話
    主站蜘蛛池模板: 亚洲乱码中文字幕小综合| 亚洲韩国精品无码一区二区三区| 日产亚洲一区二区三区| 在线观看片免费人成视频播放| 夜色阁亚洲一区二区三区| 菠萝菠萝蜜在线免费视频| 亚洲精品视频在线看| 国产大片免费天天看| 亚洲色欲久久久综合网| 青青青国产手机频在线免费观看| 亚洲V无码一区二区三区四区观看| 久久精品视频免费| 久久亚洲sm情趣捆绑调教| 免费国产成人高清在线观看网站| 亚洲13又紧又嫩又水多| 成人毛片18女人毛片免费视频未| 亚洲男同gay片| 亚洲综合国产精品第一页| 成人网站免费大全日韩国产| 久久久无码精品亚洲日韩蜜桃| 在线看片免费人成视频播| 久久亚洲AV成人出白浆无码国产 | 亚洲永久中文字幕在线| www视频在线观看免费| 亚洲一卡2卡3卡4卡乱码 在线| 女人18毛片水真多免费播放| 国产精品亚洲综合一区在线观看 | 亚洲另类激情综合偷自拍| 91麻豆最新在线人成免费观看| 四虎亚洲精品高清在线观看| 亚洲国产精品第一区二区三区| 色www永久免费网站| 亚洲国产韩国一区二区| 免费大黄网站在线观| 叮咚影视在线观看免费完整版| 亚洲大尺码专区影院| 成人伊人亚洲人综合网站222| 亚欧免费无码aⅴ在线观看| 亚洲爆乳无码专区www| 国产亚洲人成网站观看| 青春禁区视频在线观看直播免费|