This commit is contained in:
蔡玲
2024-12-04 10:21:04 +08:00
parent 9d776c65e9
commit c1ac42072f
4042 changed files with 2293732 additions and 1185 deletions

55
static/Magic4/drag.html Normal file
View File

@@ -0,0 +1,55 @@
<!DOCTYPE html>
<html>
<head>
<style>
#container {
width: 300px;
height: 300px;
border: 1px solid black;
overflow: auto;
}
#content {
width: 600px;
height: 600px;
background-color: lightgray;
}
</style>
</head>
<body>
<div id="container" onmousedown="startDrag(event)" onmouseup="stopDrag(event)" onmousemove="dragging(event)">
<div id="content">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
<p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<!-- Add more content here -->
</div>
</div>
<script>
var isDragging = false;
var container = document.getElementById('container');
var startX, startY, scrollLeft, scrollTop;
function startDrag(e) {
isDragging = true;
startX = e.clientX;
startY = e.clientY;
scrollLeft = container.scrollLeft;
scrollTop = container.scrollTop;
}
function stopDrag() {
isDragging = false;
}
function dragging(e) {
if (!isDragging) return;
var x = e.clientX - startX;
var y = e.clientY - startY;
container.scrollLeft = scrollLeft - x;
container.scrollTop = scrollTop - y;
}
</script>
</body>
</html>