zoukankan      html  css  js  c++  java
  • 拖拽回放

    <textarea name="" id="con" cols="30" rows="30"></textarea>
        <button id="btn">恢复</button>
        <div id="box"></div>
        <script>
            var con=document.getElementById('con');    
            var btn=document.getElementById('btn');    
            var box=document.getElementById('box');
            var arr=[];
            box.onmousedown=function(ev){
                var e=ev||window.event;
                var x=e.clientX-box.offsetLeft;
                var y=e.clientY-box.offsetTop;
                document.onmousemove=function(ev){
                    var e=ev||window.event;
                    var l=e.clientX-x;
                    var t=e.clientY-y;
                    con.innerHTML+='left:'+l+',top:'+t+'
    ';
                    box.style.left=l+'px';
                    box.style.top=t+'px';
                    arr.push({'left':l,'top':t});
    
                }
                document.onmouseup=function(){
                    document.onmousemove=null;
                }
                btn.onclick=function(){
                    var timer=setInterval(function(){
                        var p=arr.pop();
                        if (arr.length<=0) {
                            clearInterval(timer);
                        }else{
                            box.style.left=p.left+'px';
                            box.style.top=p.top+'px';
                        }
    
                    },10);
                }
            }    
        </script>
  • 相关阅读:
    MR架构
    概念词汇
    数仓项目06:DWD层
    Informatic学习总结_day03
    oracle_创建和管理表
    oracle_使用子查询创建表
    oracle数据类型
    文本变语音引擎 ekho
    [LNOI2014]LCA
    POJ 2942 Knights of the Round Table
  • 原文地址:https://www.cnblogs.com/SunShineM/p/6080209.html
Copyright © 2011-2022 走看看