|
@@ -252,16 +252,6 @@ export default {
|
|
// 计算元素的位置
|
|
// 计算元素的位置
|
|
_this.dragData.left = event.pageX - _this.dragData.x - 40;
|
|
_this.dragData.left = event.pageX - _this.dragData.x - 40;
|
|
_this.dragData.top = event.pageY - _this.dragData.y - 90;
|
|
_this.dragData.top = event.pageY - _this.dragData.y - 90;
|
|
- console.log("_this.dragData.left:", _this.dragData.left);
|
|
|
|
- console.log("_this.dragData.top:", _this.dragData.top);
|
|
|
|
- console.log(
|
|
|
|
- " _this.$refs.centerBox.offsetLeft:",
|
|
|
|
- _this.$refs.centerBox.offsetLeft
|
|
|
|
- );
|
|
|
|
- console.log(
|
|
|
|
- "_this.$refs.centerBox.offsetTop:",
|
|
|
|
- _this.$refs.centerBox.offsetTop
|
|
|
|
- );
|
|
|
|
const isToRight =
|
|
const isToRight =
|
|
_this.dragData.left > _this.$refs.centerBox.offsetLeft;
|
|
_this.dragData.left > _this.$refs.centerBox.offsetLeft;
|
|
const isToLeft = _this.dragData.left < _this.$refs.centerBox.offsetLeft;
|
|
const isToLeft = _this.dragData.left < _this.$refs.centerBox.offsetLeft;
|
|
@@ -282,8 +272,7 @@ export default {
|
|
if (
|
|
if (
|
|
!(
|
|
!(
|
|
(_this.$refs.centerBox.offsetWidth <= _this.maxWidth &&
|
|
(_this.$refs.centerBox.offsetWidth <= _this.maxWidth &&
|
|
- _this.$refs.centerBox.offsetWidth +
|
|
|
|
- parseFloat(_this.$refs.centerBox.style.left) >=
|
|
|
|
|
|
+ _this.$refs.centerBox.offsetWidth + _this.dragData.left >=
|
|
_this.maxWidth) ||
|
|
_this.maxWidth) ||
|
|
(_this.$refs.centerBox.offsetWidth > _this.maxWidth &&
|
|
(_this.$refs.centerBox.offsetWidth > _this.maxWidth &&
|
|
_this.dragData.left >= 0)
|
|
_this.dragData.left >= 0)
|
|
@@ -294,11 +283,10 @@ export default {
|
|
} else if (isToLeft) {
|
|
} else if (isToLeft) {
|
|
if (
|
|
if (
|
|
!(
|
|
!(
|
|
- (parseFloat(_this.$refs.centerBox.style.left) <= 0 &&
|
|
|
|
|
|
+ (_this.dragData.left <= 0 &&
|
|
_this.$refs.centerBox.offsetWidth <= _this.maxWidth) ||
|
|
_this.$refs.centerBox.offsetWidth <= _this.maxWidth) ||
|
|
- (parseFloat(_this.$refs.centerBox.style.left) <= 0 &&
|
|
|
|
- _this.$refs.centerBox.offsetWidth +
|
|
|
|
- parseFloat(_this.$refs.centerBox.style.left) <=
|
|
|
|
|
|
+ (_this.dragData.left <= 0 &&
|
|
|
|
+ _this.$refs.centerBox.offsetWidth + _this.dragData.left <=
|
|
_this.maxWidth)
|
|
_this.maxWidth)
|
|
)
|
|
)
|
|
) {
|
|
) {
|
|
@@ -308,11 +296,10 @@ export default {
|
|
if (isToTop) {
|
|
if (isToTop) {
|
|
if (
|
|
if (
|
|
!(
|
|
!(
|
|
- (parseFloat(_this.$refs.centerBox.style.top) <= 0 &&
|
|
|
|
|
|
+ (_this.dragData.top <= 0 &&
|
|
_this.$refs.centerBox.offsetHeight <= _this.maxHeight) ||
|
|
_this.$refs.centerBox.offsetHeight <= _this.maxHeight) ||
|
|
- (parseFloat(_this.$refs.centerBox.style.top) <= 0 &&
|
|
|
|
- _this.$refs.centerBox.offsetHeight +
|
|
|
|
- parseFloat(_this.$refs.centerBox.style.top) <=
|
|
|
|
|
|
+ (_this.dragData.top <= 0 &&
|
|
|
|
+ _this.$refs.centerBox.offsetHeight + _this.dragData.top <=
|
|
_this.maxHeight)
|
|
_this.maxHeight)
|
|
)
|
|
)
|
|
) {
|
|
) {
|
|
@@ -323,8 +310,7 @@ export default {
|
|
if (
|
|
if (
|
|
!(
|
|
!(
|
|
(_this.$refs.centerBox.offsetHeight <= _this.maxHeight &&
|
|
(_this.$refs.centerBox.offsetHeight <= _this.maxHeight &&
|
|
- _this.$refs.centerBox.offsetHeight +
|
|
|
|
- parseFloat(_this.$refs.centerBox.style.top) >=
|
|
|
|
|
|
+ _this.$refs.centerBox.offsetHeight + _this.dragData.top >=
|
|
_this.maxHeight) ||
|
|
_this.maxHeight) ||
|
|
(_this.$refs.centerBox.offsetHeight > _this.maxHeight &&
|
|
(_this.$refs.centerBox.offsetHeight > _this.maxHeight &&
|
|
_this.dragData.top >= 0)
|
|
_this.dragData.top >= 0)
|