Skip to content

NotYmL/draggable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

draggable

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;}})}

draggable(GrabPiont, ElementToMove)

alt text

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published