Add files via upload

This commit is contained in:
Cola-Echo
2025-12-30 01:25:12 +08:00
committed by GitHub
parent 1b3ec1d43f
commit c97f2958ce
12 changed files with 1340 additions and 106 deletions

17
main.js
View File

@@ -538,8 +538,21 @@ function onMinimizedDragMove(e) {
minimizeState.hasMoved = true;
}
const newLeft = minimizeState.initialLeft + deltaX;
const newTop = minimizeState.initialTop + deltaY;
// 直接使用当前触摸/鼠标位置减去元素尺寸的一半,让元素中心跟随手指
const scale = 0.25;
const rect = phone.getBoundingClientRect();
const scaledWidth = rect.width;
const scaledHeight = rect.height;
// 计算新位置:让缩小后的手机中心跟随手指
let newLeft = clientX - scaledWidth / 2;
let newTop = clientY - scaledHeight / 2;
// 限制在视口内
const maxX = window.innerWidth - scaledWidth;
const maxY = window.innerHeight - scaledHeight;
newLeft = Math.min(Math.max(0, newLeft), maxX);
newTop = Math.min(Math.max(0, newTop), maxY);
phone.style.left = newLeft + 'px';
phone.style.top = newTop + 'px';