NEZ-1855 fix: 多个 group 折叠后 拖拽位置不对的问题
This commit is contained in:
@@ -664,8 +664,8 @@ export default {
|
||||
// 0 * Infinity === NaN, which causes problems with resize constriants;
|
||||
// Fix this if it occurs.
|
||||
// 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],
|
||||
height: h === Infinity ? h : this.rowHeight * h + Math.max(0, h - 1) * this.margin[1]
|
||||
width: w === Infinity ? w : Math.round(colWidth * w + Math.max(0, w - 1) * this.margin[0]),
|
||||
height: h === Infinity ? h : Math.round(this.rowHeight * h + Math.max(0, h - 1) * this.margin[1])
|
||||
}
|
||||
} else {
|
||||
out = {
|
||||
@@ -674,8 +674,8 @@ export default {
|
||||
// 0 * Infinity === NaN, which causes problems with resize constriants;
|
||||
// Fix this if it occurs.
|
||||
// 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],
|
||||
height: h === Infinity ? h : this.rowHeight * h + Math.max(0, h - 1) * this.margin[1]
|
||||
width: w === Infinity ? w : Math.round(colWidth * w + Math.max(0, w - 1) * this.margin[0]),
|
||||
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))
|
||||
// ...
|
||||
// w = (width + margin) / (colWidth + margin)
|
||||
let w = (width + this.margin[0]) / (colWidth + this.margin[0])
|
||||
let h = (height + this.margin[1]) / (this.rowHeight + this.margin[1])
|
||||
let w = Math.round((width + this.margin[0]) / (colWidth + this.margin[0]))
|
||||
let h = Math.round((height + this.margin[1]) / (this.rowHeight + this.margin[1]))
|
||||
|
||||
// Capping
|
||||
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) {
|
||||
// console.log(eventName + " id=" + id + ", x=" + x + ", y=" + y);
|
||||
if (!window.index) window.index = 1
|
||||
let l = getLayoutItem(this.layout, id)
|
||||
// GetLayoutItem sometimes returns null object
|
||||
if (l === undefined || l === null) {
|
||||
|
||||
@@ -227,8 +227,7 @@ export function moveElement (layout, l, x, y, isUserAction, preventCollision) {
|
||||
// nearest collision.
|
||||
let sorted = sortLayoutItemsByRowCol(layout)
|
||||
if (movingUp) sorted = sorted.reverse()
|
||||
const collisions = getAllCollisions(sorted, l)
|
||||
|
||||
let collisions = getAllCollisions(sorted, l)
|
||||
if (preventCollision && collisions.length) {
|
||||
l.x = oldX
|
||||
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.
|
||||
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]
|
||||
// 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.
|
||||
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.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
|
||||
// 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
|
||||
const nowImage = getTopologyImg(item.id) ? JSON.parse(getTopologyImg(item.id)) : ''
|
||||
if (nowImage && nowImage.data) {
|
||||
console.log(nowImage)
|
||||
promiseArr.push(nowImage)
|
||||
} else {
|
||||
promiseArr.push(this.dealImg(`monitor/project/topo/icon/${item.id}/1`))
|
||||
|
||||
@@ -1743,7 +1743,6 @@ export default {
|
||||
delete item.name
|
||||
const nowImage = getTopologyImg(item.id) ? JSON.parse(getTopologyImg(item.id)) : ''
|
||||
if (nowImage && nowImage.data) {
|
||||
console.log(nowImage)
|
||||
promiseArr.push(nowImage)
|
||||
} else {
|
||||
promiseArr.push(this.dealImg(`monitor/project/topo/icon/${item.id}/1`))
|
||||
@@ -1751,7 +1750,6 @@ export default {
|
||||
imgArr.push({ ...item })
|
||||
})
|
||||
Promise.all(promiseArr).then((res2, header) => {
|
||||
console.log(res2, 'Promise')
|
||||
this.iconArray = [...res.data.list]
|
||||
this.iconArray.forEach((item, index) => {
|
||||
item.image = res2[index].data
|
||||
|
||||
Reference in New Issue
Block a user