禁止widget移出画布边界

qianming 2 years ago
parent afa50789af
commit 60f722c3c6

@ -106,7 +106,9 @@ export default {
data: {
setup: {},
data: {},
position: {}
position: {},
leftMargin: null,
topMargin: null
}
};
},
@ -118,10 +120,10 @@ export default {
return this.value.position.height;
},
widgetsLeft() {
return this.value.position.left;
return this.value.position.left >= this.leftMargin ? this.leftMargin : this.value.position.left;
},
widgetsTop() {
return this.value.position.top;
return this.value.position.top >= this.topMargin ? this.topMargin : this.value.position.top;
},
widgetsZIndex() {
return this.value.position.zIndex || 1;
@ -133,6 +135,28 @@ export default {
handleBlur({ index, left, top, width, height }) {
this.$emit("onActivated", { index, left, top, width, height });
this.$refs.draggable.setActive(true);
// widgetworkbench
this.handleBoundary({ index, left, top, width, height })
},
handleBoundary({ index, left, top, width, height }) {
// workbenchX
// + > = ( - ) = 0
const { bigscreenWidth, bigscreenHeight } = this.bigscreen;
const xBoundaryValue = (left + width) > bigscreenWidth ? bigscreenWidth - width : left < 0 ? 0 : left;
// X
this.leftMargin = left;
// Y
const yBoundaryValue = (top + height) > bigscreenHeight ? bigscreenHeight - height : top < 0 ? 0 : top;
// Y
this.topMargin = top;
//
if (this.leftMargin != xBoundaryValue || this.topMargin != yBoundaryValue) {
this.$nextTick(() => {
this.leftMargin = xBoundaryValue;
this.topMargin = yBoundaryValue;
this.$emit("onActivated", { index, left: xBoundaryValue, top: yBoundaryValue, width, height });
})
}
}
}
};

Loading…
Cancel
Save