This commit is contained in:
Joseph Cheung 2023-03-02 18:10:05 +08:00
parent 2d1529918f
commit f350a105f2
2 changed files with 10 additions and 12 deletions

View file

@ -911,13 +911,12 @@ def search():
}) })
}) })
modal.addEventListener('touchstart', function (e) { modal.addEventListener('touchstart', function (e) {
var x = e.targetTouches[0].pageX - modal.offsetLeft; var x = e.touches[0].pageX - modal.offsetLeft;
var y = e.targetTouches[0].pageY - modal.offsetTop; var y = e.touches[0].pageY - modal.offsetTop;
// (2) 鼠标移动的时候把鼠标在页面中的坐标减去 鼠标在盒子内的坐标就是模态框的left和top值 document.addEventListener('touchmove', move)
document.addEventListener('touchmove ', move)
function move(e) { function move(e) {
modal.style.left = e.targetTouches[0].pageX - x + 'px'; modal.style.left = e.touches[0].pageX - x + 'px';
modal.style.top = e.targetTouches[0].pageY - y + 'px'; modal.style.top = e.touches[0].pageY - y + 'px';
} }
// (3) 鼠标弹起就让鼠标移动事件移除 // (3) 鼠标弹起就让鼠标移动事件移除
document.addEventListener('touchend', function () { document.addEventListener('touchend', function () {

View file

@ -911,13 +911,12 @@ def search():
}) })
}) })
modal.addEventListener('touchstart', function (e) { modal.addEventListener('touchstart', function (e) {
var x = e.targetTouches[0].pageX - modal.offsetLeft; var x = e.touches[0].pageX - modal.offsetLeft;
var y = e.targetTouches[0].pageY - modal.offsetTop; var y = e.touches[0].pageY - modal.offsetTop;
// (2) 鼠标移动的时候把鼠标在页面中的坐标减去 鼠标在盒子内的坐标就是模态框的left和top值 document.addEventListener('touchmove', move)
document.addEventListener('touchmove ', move)
function move(e) { function move(e) {
modal.style.left = e.targetTouches[0].pageX - x + 'px'; modal.style.left = e.touches[0].pageX - x + 'px';
modal.style.top = e.targetTouches[0].pageY - y + 'px'; modal.style.top = e.touches[0].pageY - y + 'px';
} }
// (3) 鼠标弹起就让鼠标移动事件移除 // (3) 鼠标弹起就让鼠标移动事件移除
document.addEventListener('touchend', function () { document.addEventListener('touchend', function () {