mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-14 10:39:27 +00:00
update(Dashboard grid): doesnt allow the user to drag a widget outside of the grid boundaries
This commit is contained in:
@@ -159,7 +159,7 @@ export default {
|
||||
// this.$emit('setConfig', true); -> use this to enable widget config mode if needed
|
||||
},
|
||||
template: /*html*/ `
|
||||
<div class="widgets-url w-100 h-100 overflow-scroll" style="padding: 1rem 1rem;">
|
||||
<div class="widgets-url w-100 h-100 overflow-auto" style="padding: 1rem 1rem;">
|
||||
<div class="d-flex flex-column justify-content-between">
|
||||
<button class="btn btn-outline-secondary btn-sm w-100 mt-2 card" @click="openCreateModal" type="button">{{$p.t('bookmark','newLink')}}</button>
|
||||
|
||||
|
||||
@@ -274,8 +274,23 @@ export default {
|
||||
dragging(event){
|
||||
if(this.mode == MODE_MOVE){
|
||||
this.toggleDraggedItemOverlay(true);
|
||||
this.clonedWidget.style.top = `${this.clientY-20}px`;
|
||||
this.clonedWidget.style.left = `${this.clientX-15}px`;
|
||||
|
||||
const containerRect = this.$refs.container.getBoundingClientRect();
|
||||
const clonedWidgetRect = this.clonedWidget.getBoundingClientRect();
|
||||
|
||||
let desiredTop = this.clientY - 20;
|
||||
let desiredLeft = this.clientX - 15;
|
||||
|
||||
const minTop = 0;
|
||||
const maxTop = containerRect.height - clonedWidgetRect.height;
|
||||
const minLeft = 0;
|
||||
const maxLeft = containerRect.width - clonedWidgetRect.width;
|
||||
|
||||
const constrainedTop = Math.max(minTop, Math.min(maxTop, desiredTop));
|
||||
const constrainedLeft = Math.max(minLeft, Math.min(maxLeft, desiredLeft));
|
||||
|
||||
this.clonedWidget.style.top = `${constrainedTop}px`;
|
||||
this.clonedWidget.style.left = `${constrainedLeft}px`;
|
||||
}
|
||||
},
|
||||
createNewGrid(items) {
|
||||
@@ -413,6 +428,7 @@ export default {
|
||||
setTimeout(() => {
|
||||
this.draggedNode = evt.target.closest(".drop-grid-item");
|
||||
//clones the widget for the drag Image
|
||||
|
||||
let clone = evt.target.closest(".drop-grid-item")?.cloneNode(true);
|
||||
|
||||
clone.style.zIndex = 5;
|
||||
|
||||
Reference in New Issue
Block a user