forked from Stirling-Tools/Stirling-PDF
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add on hover color to sign (Stirling-Tools#2059)
* Fixed layering issue with z-index, and added smoother transitions for… (Stirling-Tools#1996) Fixed layering issue with z-index, and added smoother transitions for signing Co-authored-by: Anthony Stirling <[email protected]> * Delete package-lock.json --------- Co-authored-by: Surya Karthikeyan Vijayalakshmi <[email protected]>
- Loading branch information
1 parent
04d5ae1
commit cae8cd0
Showing
3 changed files
with
307 additions
and
245 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const draggableElement = document.querySelector('.draggable-canvas'); | ||
|
||
// Variables to store the current position of the draggable element | ||
let offsetX, offsetY, isDragging = false; | ||
|
||
draggableElement.addEventListener('mousedown', (e) => { | ||
// Get the offset when the mouse is clicked inside the element | ||
offsetX = e.clientX - draggableElement.getBoundingClientRect().left; | ||
offsetY = e.clientY - draggableElement.getBoundingClientRect().top; | ||
|
||
// Set isDragging to true | ||
isDragging = true; | ||
|
||
// Add event listeners for mouse movement and release | ||
document.addEventListener('mousemove', onMouseMove); | ||
document.addEventListener('mouseup', onMouseUp); | ||
}); | ||
|
||
function onMouseMove(e) { | ||
if (isDragging) { | ||
// Calculate the new position of the element | ||
const left = e.clientX - offsetX; | ||
const top = e.clientY - offsetY; | ||
|
||
// Move the element by setting its style | ||
draggableElement.style.left = `${left}px`; | ||
draggableElement.style.top = `${top}px`; | ||
} | ||
} | ||
|
||
function onMouseUp() { | ||
// Stop dragging and remove event listeners | ||
isDragging = false; | ||
document.removeEventListener('mousemove', onMouseMove); | ||
document.removeEventListener('mouseup', onMouseUp); | ||
} |
Oops, something went wrong.