Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
NotYmL authored Jul 12, 2022
1 parent 0db267b commit 755ec06
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
# draggable
# draggable

```js
async function draggable(grabP, move){let lastPosX = null;let lastPosY = null;let op = document.body.getElementsByTagName("*");for(let i = 0; i < op.length; i++) {Object.assign(op[i].style, {userSelect: "none"});}move.style.position = "absolute";grabP.addEventListener("mousemove", (e) => {if(e['buttons']==1) {move.style.left = `${move.offsetLeft - (lastPosX - e.clientX)}px`;move.style.top = `${move.offsetTop - (lastPosY - e.clientY)}px`;lastPosY=e.clientY;lastPosX=e.clientX;}else{lastPosX=e.clientX; lastPosY=e.clientY;}})}
```

0 comments on commit 755ec06

Please sign in to comment.