mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2024-12-31 00:08:08 +01:00
Merge pull request #2485 from omar-ahmed42/fix-2478-draggableElement-null
Fix draggableElement is null by removing draggable.js
This commit is contained in:
commit
8053035158
@ -1,36 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
@ -236,9 +236,6 @@
|
|||||||
</div>
|
</div>
|
||||||
<th:block th:insert="~{fragments/footer.html :: footer}"></th:block>
|
<th:block th:insert="~{fragments/footer.html :: footer}"></th:block>
|
||||||
</div>
|
</div>
|
||||||
<!-- Link the draggable.js file -->
|
|
||||||
<script th:src="@{'/js/draggable.js'}"></script>
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
Loading…
Reference in New Issue
Block a user