NEZ-1855 fix: 多个 group 折叠后 拖拽位置不对的问题
This commit is contained in:
@@ -664,8 +664,8 @@ export default {
|
|||||||
// 0 * Infinity === NaN, which causes problems with resize constriants;
|
// 0 * Infinity === NaN, which causes problems with resize constriants;
|
||||||
// Fix this if it occurs.
|
// Fix this if it occurs.
|
||||||
// Note we do it here rather than later because Math.round(Infinity) causes deopt
|
// Note we do it here rather than later because Math.round(Infinity) causes deopt
|
||||||
width: w === Infinity ? w : colWidth * w + Math.max(0, w - 1) * this.margin[0],
|
width: w === Infinity ? w : Math.round(colWidth * w + Math.max(0, w - 1) * this.margin[0]),
|
||||||
height: h === Infinity ? h : this.rowHeight * h + Math.max(0, h - 1) * this.margin[1]
|
height: h === Infinity ? h : Math.round(this.rowHeight * h + Math.max(0, h - 1) * this.margin[1])
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
out = {
|
out = {
|
||||||
@@ -674,8 +674,8 @@ export default {
|
|||||||
// 0 * Infinity === NaN, which causes problems with resize constriants;
|
// 0 * Infinity === NaN, which causes problems with resize constriants;
|
||||||
// Fix this if it occurs.
|
// Fix this if it occurs.
|
||||||
// Note we do it here rather than later because Math.round(Infinity) causes deopt
|
// Note we do it here rather than later because Math.round(Infinity) causes deopt
|
||||||
width: w === Infinity ? w : colWidth * w + Math.max(0, w - 1) * this.margin[0],
|
width: w === Infinity ? w : Math.round(colWidth * w + Math.max(0, w - 1) * this.margin[0]),
|
||||||
height: h === Infinity ? h : this.rowHeight * h + Math.max(0, h - 1) * this.margin[1]
|
height: h === Infinity ? h : Math.round(this.rowHeight * h + Math.max(0, h - 1) * this.margin[1])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -726,8 +726,8 @@ export default {
|
|||||||
// width = colWidth * w - (margin * (w - 1))
|
// width = colWidth * w - (margin * (w - 1))
|
||||||
// ...
|
// ...
|
||||||
// w = (width + margin) / (colWidth + margin)
|
// w = (width + margin) / (colWidth + margin)
|
||||||
let w = (width + this.margin[0]) / (colWidth + this.margin[0])
|
let w = Math.round((width + this.margin[0]) / (colWidth + this.margin[0]))
|
||||||
let h = (height + this.margin[1]) / (this.rowHeight + this.margin[1])
|
let h = Math.round((height + this.margin[1]) / (this.rowHeight + this.margin[1]))
|
||||||
|
|
||||||
// Capping
|
// Capping
|
||||||
w = Math.max(Math.min(w, this.cols - this.innerX), 0)
|
w = Math.max(Math.min(w, this.cols - this.innerX), 0)
|
||||||
|
|||||||
@@ -302,6 +302,7 @@ export default {
|
|||||||
},
|
},
|
||||||
dragEvent: function (eventName, id, x, y, h, w) {
|
dragEvent: function (eventName, id, x, y, h, w) {
|
||||||
// console.log(eventName + " id=" + id + ", x=" + x + ", y=" + y);
|
// console.log(eventName + " id=" + id + ", x=" + x + ", y=" + y);
|
||||||
|
if (!window.index) window.index = 1
|
||||||
let l = getLayoutItem(this.layout, id)
|
let l = getLayoutItem(this.layout, id)
|
||||||
// GetLayoutItem sometimes returns null object
|
// GetLayoutItem sometimes returns null object
|
||||||
if (l === undefined || l === null) {
|
if (l === undefined || l === null) {
|
||||||
|
|||||||
@@ -227,8 +227,7 @@ export function moveElement (layout, l, x, y, isUserAction, preventCollision) {
|
|||||||
// nearest collision.
|
// nearest collision.
|
||||||
let sorted = sortLayoutItemsByRowCol(layout)
|
let sorted = sortLayoutItemsByRowCol(layout)
|
||||||
if (movingUp) sorted = sorted.reverse()
|
if (movingUp) sorted = sorted.reverse()
|
||||||
const collisions = getAllCollisions(sorted, l)
|
let collisions = getAllCollisions(sorted, l)
|
||||||
|
|
||||||
if (preventCollision && collisions.length) {
|
if (preventCollision && collisions.length) {
|
||||||
l.x = oldX
|
l.x = oldX
|
||||||
l.y = oldY
|
l.y = oldY
|
||||||
@@ -237,7 +236,6 @@ export function moveElement (layout, l, x, y, isUserAction, preventCollision) {
|
|||||||
}
|
}
|
||||||
// Move each item that collides away from this element.
|
// Move each item that collides away from this element.
|
||||||
for (let i = 0, len = collisions.length; i < len; i++) {
|
for (let i = 0, len = collisions.length; i < len; i++) {
|
||||||
console.log(collisions, collisions[0].name, collisions[0].y, collisions[0].h,' collisions')
|
|
||||||
const collision = collisions[i]
|
const collision = collisions[i]
|
||||||
// console.log('resolving collision between', l.i, 'at', l.y, 'and', collision.i, 'at', collision.y);
|
// console.log('resolving collision between', l.i, 'at', l.y, 'and', collision.i, 'at', collision.y);
|
||||||
|
|
||||||
@@ -246,7 +244,6 @@ export function moveElement (layout, l, x, y, isUserAction, preventCollision) {
|
|||||||
|
|
||||||
// This makes it feel a bit more precise by waiting to swap for just a bit when moving up.
|
// This makes it feel a bit more precise by waiting to swap for just a bit when moving up.
|
||||||
if (l.y > collision.y && l.y - collision.y > collision.h / 4) continue
|
if (l.y > collision.y && l.y - collision.y > collision.h / 4) continue
|
||||||
console.log(l.y, l.y - collision.y > collision.h / 4, l.y > collision.y )
|
|
||||||
if (l.type == 'group') {
|
if (l.type == 'group') {
|
||||||
if (l.y + l.h > collision.y && l.y + l.h - collision.y > collision.h / 4) continue
|
if (l.y + l.h > collision.y && l.y + l.h - collision.y > collision.h / 4) continue
|
||||||
}
|
}
|
||||||
@@ -294,7 +291,8 @@ export function moveElementAwayFromCollision (layout, collidesWith, itemToMove,
|
|||||||
|
|
||||||
// Previously this was optimized to move below the collision directly, but this can cause problems
|
// Previously this was optimized to move below the collision directly, but this can cause problems
|
||||||
// with cascading moves, as an item may actually leapflog a collision and cause a reversal in order.
|
// with cascading moves, as an item may actually leapflog a collision and cause a reversal in order.
|
||||||
return moveElement(layout, itemToMove, undefined, itemToMove.y + 1, preventCollision)
|
|
||||||
|
return moveElement(layout, itemToMove, undefined, itemToMove.y + 0.15, preventCollision)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1746,7 +1746,6 @@ export default {
|
|||||||
delete item.name
|
delete item.name
|
||||||
const nowImage = getTopologyImg(item.id) ? JSON.parse(getTopologyImg(item.id)) : ''
|
const nowImage = getTopologyImg(item.id) ? JSON.parse(getTopologyImg(item.id)) : ''
|
||||||
if (nowImage && nowImage.data) {
|
if (nowImage && nowImage.data) {
|
||||||
console.log(nowImage)
|
|
||||||
promiseArr.push(nowImage)
|
promiseArr.push(nowImage)
|
||||||
} else {
|
} else {
|
||||||
promiseArr.push(this.dealImg(`monitor/project/topo/icon/${item.id}/1`))
|
promiseArr.push(this.dealImg(`monitor/project/topo/icon/${item.id}/1`))
|
||||||
|
|||||||
@@ -1743,7 +1743,6 @@ export default {
|
|||||||
delete item.name
|
delete item.name
|
||||||
const nowImage = getTopologyImg(item.id) ? JSON.parse(getTopologyImg(item.id)) : ''
|
const nowImage = getTopologyImg(item.id) ? JSON.parse(getTopologyImg(item.id)) : ''
|
||||||
if (nowImage && nowImage.data) {
|
if (nowImage && nowImage.data) {
|
||||||
console.log(nowImage)
|
|
||||||
promiseArr.push(nowImage)
|
promiseArr.push(nowImage)
|
||||||
} else {
|
} else {
|
||||||
promiseArr.push(this.dealImg(`monitor/project/topo/icon/${item.id}/1`))
|
promiseArr.push(this.dealImg(`monitor/project/topo/icon/${item.id}/1`))
|
||||||
@@ -1751,7 +1750,6 @@ export default {
|
|||||||
imgArr.push({ ...item })
|
imgArr.push({ ...item })
|
||||||
})
|
})
|
||||||
Promise.all(promiseArr).then((res2, header) => {
|
Promise.all(promiseArr).then((res2, header) => {
|
||||||
console.log(res2, 'Promise')
|
|
||||||
this.iconArray = [...res.data.list]
|
this.iconArray = [...res.data.list]
|
||||||
this.iconArray.forEach((item, index) => {
|
this.iconArray.forEach((item, index) => {
|
||||||
item.image = res2[index].data
|
item.image = res2[index].data
|
||||||
|
|||||||
Reference in New Issue
Block a user