Created
August 12, 2018 13:03
-
-
Save knomdlo/28f420106a9b273749e126c34486cbef to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
function myfunc(e) { | |
let ele = document.getElementById('my-dialog'); | |
ele.style["left"] = | |
(window.innerWidth - e.pageX) < ele.offsetWidth ? e.pageX - ele.offsetWidth : e.pageX; | |
ele.style["top"] = | |
(window.innerHeight - e.pageY) < ele.offsetHeight ? e.pageY - ele.offsetHeight : e.pageY; | |
} | |
document.onclick = myfunc; | |
</script> | |
<body> | |
<div id="my-dialog" style="position: absolute;width: 100px; | |
height: 200px;background: grey;"> | |
</div> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment