js浠g爜瀹炵幇鎷栨嫿

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了js浠g爜瀹炵幇鎷栨嫿相关的知识,希望对你有一定的参考价值。

鏍囩锛?a href='http://www.mamicode.com/so/1/event' title='event'>event   doc   style   绉诲姩   鍧愭爣   false   move   瀹炵幇   璁$畻   

寰堢畝鍗曠殑鎬濊矾锛岄€氳繃涓変釜榧犳爣浜嬩欢锛氱偣鍑汇€佺Щ鍔ㄣ€佹姮璧凤紝鍙璁$畻鍑哄綋鍓嶄綅缃嵆鍙紝濡傛灉鏄浘鐗囩殑璇濆姞鍏ワ細e.preventDefault();鍗冲彲

//鑾峰彇鍏冪礌
var dv = document.getElementById(鈥榙v鈥?span style="color: rgba(0, 0, 0, 1)">);
var x = 0;
var y = 0;
var l = 0;
var t = 0;
var isDown = false;
//榧犳爣鎸変笅浜嬩欢
dv.onmousedown = function(e) {
    //鑾峰彇x鍧愭爣鍜寉鍧愭爣
    x = e.clientX;
    y = e.clientY;

    //鑾峰彇宸﹂儴鍜岄《閮ㄧ殑鍋忕Щ閲?/span>
    l = dv.offsetLeft;
    t = dv.offsetTop;
    //寮€鍏虫墦寮€
    isDown = true;
    //璁剧疆鏍峰紡  
    dv.style.cursor = 鈥榤ove鈥?span style="color: rgba(0, 0, 0, 1)">;
}
//榧犳爣绉诲姩
window.onmousemove = function(e) {
    if (isDown == false) {
        return;
    }
    //鑾峰彇x鍜寉
    var nx = e.clientX;
    var ny = e.clientY;
    //璁$畻绉诲姩鍚庣殑宸﹀亸绉婚噺鍜岄《閮ㄧ殑鍋忕Щ閲?/span>
    var nl = nx - (x - l);
    var nt = ny - (y - t);

    dv.style.left = nl + 鈥榩x鈥?span style="color: rgba(0, 0, 0, 1)">;
    dv.style.top = nt + 鈥榩x鈥?span style="color: rgba(0, 0, 0, 1)">;
}
//榧犳爣鎶捣浜嬩欢
dv.onmouseup = function() {
    //寮€鍏冲叧闂?/span>
    isDown = false;
    dv.style.cursor = 鈥榙efault鈥?span style="color: rgba(0, 0, 0, 1)">;
}

 

以上是关于js浠g爜瀹炵幇鎷栨嫿的主要内容,如果未能解决你的问题,请参考以下文章

娣卞害瀛︿範鍘熺悊璇﹁В鍙奝ython浠g爜瀹炵幇

Dubbo鎺ュ彛涓嶇煡閬撴€庝箞娴嬶紵鏁欎綘涓夎浠g爜瀹炵幇dubbo鎺ュ彛娴嬭瘯

HttpClient 瀹炵幇 socks 浠g悊

瀹炵幇涓€涓唬鐮佺紪璇戝櫒锛?00琛孞S浠g爜锛?/h1>

Mybatis 浠g爜瀹炶返

arcgis for js鍒涘缓闅忓湴鍥剧缉鏀剧殑鐐?/a>