mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-14 21:53:35 +03:00
06e0ea5e24
To avoid rounding errors, make coordinates even.
58 lines
1.1 KiB
HTML
58 lines
1.1 KiB
HTML
<style>
|
|
* {
|
|
box-sizing: border-box;
|
|
}
|
|
body, html {
|
|
margin: 0;
|
|
padding: 0;
|
|
}
|
|
div:not(.mouse-helper) {
|
|
margin: 0;
|
|
padding: 0;
|
|
}
|
|
#source {
|
|
color: blue;
|
|
border: 1px solid black;
|
|
position: absolute;
|
|
left: 20px;
|
|
top: 20px;
|
|
width: 200px;
|
|
height: 100px;
|
|
}
|
|
#target {
|
|
border: 1px solid black;
|
|
position: absolute;
|
|
left: 40px;
|
|
top: 200px;
|
|
width: 400px;
|
|
height: 300px;
|
|
}
|
|
</style>
|
|
|
|
<script>
|
|
|
|
function dragstart_handler(ev) {
|
|
ev.currentTarget.style.border = "dashed";
|
|
ev.dataTransfer.setData("text/plain", ev.target.id);
|
|
}
|
|
|
|
function dragover_handler(ev) {
|
|
ev.preventDefault();
|
|
}
|
|
|
|
function drop_handler(ev) {
|
|
console.log("Drop");
|
|
ev.preventDefault();
|
|
var data = ev.dataTransfer.getData("text");
|
|
ev.target.appendChild(document.getElementById(data));
|
|
}
|
|
</script>
|
|
|
|
<body>
|
|
<div>
|
|
<p id="source" ondragstart="dragstart_handler(event);" draggable="true">
|
|
Select this element, drag it to the Drop Zone and then release the selection to move the element.</p>
|
|
</div>
|
|
<div id="target" ondrop="drop_handler(event);" ondragover="dragover_handler(event);">Drop Zone</div>
|
|
</body>
|