Skip to content

Commit

Permalink
Add on hover color to sign (Stirling-Tools#2059)
Browse files Browse the repository at this point in the history
* 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
Frooodle and SuryaKV101 authored Oct 21, 2024
1 parent 04d5ae1 commit cae8cd0
Show file tree
Hide file tree
Showing 3 changed files with 307 additions and 245 deletions.
35 changes: 30 additions & 5 deletions src/main/resources/static/css/sign.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
select#font-select,
select#font-select option {
height: 60px; /* Adjust as needed */
font-size: 30px; /* Adjust as needed */
height: 60px;
/* Adjust as needed */
font-size: 30px;
/* Adjust as needed */
}

.drawing-pad-container {
Expand All @@ -13,27 +15,50 @@ select#font-select option {
width: 100%;
height: 300px;
}

#box-drag-container {
position: relative;
margin: 20px 0;
}

.draggable-buttons-box {
position: absolute;
top: 0;
padding: 10px;
width: 100%;
display: flex;
gap: 5px;
z-index: 5;
}
.draggable-buttons-box > button {
z-index: 10;

.draggable-buttons-box>button {
z-index: 4;
background-color: rgba(13, 110, 253, 0.1);
}

.draggable-canvas {
border: 1px solid red;
border: 2px solid #3498db;
position: absolute;
touch-action: none;
user-select: none;
top: 0px;
left: 0;
z-index: 100;
cursor: grab;
transition: transform 0.1s ease-out;
background-color: rgba(52, 152, 219, 0.1);
/* Light blue background */
}

.draggable-canvas:active {
cursor: grabbing;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
/* Shadow on active drag */
}

.draggable-canvas:hover {
border: 2px solid #2980b9;
/* Darker border on hover */
background-color: rgba(52, 152, 219, 0.2);
/* Darken background on hover */
}
36 changes: 36 additions & 0 deletions src/main/resources/static/js/draggable.js
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);
}
Loading

0 comments on commit cae8cd0

Please sign in to comment.