<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

    搜索

    •  

    最新評論

    閱讀排行榜

    校園夢網網絡電話,中國最優秀的網絡電話
    主站蜘蛛池模板: 亚洲国产精品第一区二区三区| 成人永久免费高清| 欧洲 亚洲 国产图片综合| 国产精品久久免费视频| 国产免费一区二区视频| 亚洲人成黄网在线观看| 亚洲а∨天堂久久精品| 免费国产污网站在线观看15| 亚洲色偷偷综合亚洲av78| 国产精品亚洲成在人线| 成人激情免费视频| a毛看片免费观看视频| 亚洲熟女精品中文字幕| 国产成人亚洲精品青草天美| 毛片免费视频播放| 全黄大全大色全免费大片| 欧洲亚洲国产精华液| 亚洲大片在线观看| 亚洲国产精品自产在线播放| 免费国产污网站在线观看15| igao激情在线视频免费| 亚洲成年网站在线观看| 日韩亚洲一区二区三区| 免费一级成人毛片| 日韩毛片免费无码无毒视频观看| 成人免费av一区二区三区| 亚洲精品久久无码av片俺去也| 亚洲欧洲日产国码久在线观看| 四虎影视永久免费观看地址| 1000部啪啪毛片免费看| 成人自慰女黄网站免费大全| 亚洲heyzo专区无码综合| 亚洲国产成人久久综合一| 免费成人午夜视频| 成人免费视频小说| a毛片基地免费全部视频| 无码成A毛片免费| a色毛片免费视频| av网站免费线看| 国产成人亚洲精品播放器下载| 亚洲一卡2卡3卡4卡国产网站 |