zoukankan      html  css  js  c++  java
  • js按钮浮动随手指方向移动而移动

        window.document.getElementById("moveDIV").addEventListener("touchmove", function (event) {
                
                event.preventDefault();
                
                if (event.targetTouches.length == 1) {
                    var touch = event.targetTouches[0];  // 把元素放在手指所在的位置
                 
                    if(touch.pageX + $("#moveDIV").width() > $(window).innerWidth()){
                        
                         window.document.getElementById("moveDIV").style.left = ($(window).innerWidth() - $("#moveDIV").width()) + 'px';
                        
                    }else if(touch.pageX < $("#moveDIV").width()){
                        
                        window.document.getElementById("moveDIV").style.left = 0 + 'px';
                        
                    }else{
                        
                        window.document.getElementById("moveDIV").style.left = touch.pageX + 'px';
                    }
                    
                   if(touch.pageY + $("#moveDIV").height() > $(window).innerHeight()){
                       
                           window.document.getElementById("moveDIV").style.top = ($(window).innerHeight() - $("#moveDIV").height())+ 'px';
                           
                   }else if(touch.pageY < $("#moveDIV").height()){
                        
                        window.document.getElementById("moveDIV").style.top = 0 + 'px';
                        
                    }else {
                       
                           window.document.getElementById("moveDIV").style.top = touch.pageY + 'px';
                           
                   }
                }
            },false)

  • 相关阅读:
    kibana ,logstash and filebeat
    The Run-Time Constant Pool The Constant Pool
    hsdb
    The Dataflow Model: A Practical Approach to Balancing
    编译器
    汇编
    状态机
    lsm-tree
    Serviceability
    JIT编译器
  • 原文地址:https://www.cnblogs.com/myRain/p/6046892.html
Copyright © 2011-2022 走看看