Browse Source

fix: Fixed issue with dnd to last col and improved auto scrolling responsiveness

pull/6815/head
Muhammed Mustafa 1 year ago
parent
commit
d7211b8265
  1. 15
      packages/nc-gui/components/smartsheet/grid/useColumnDrag.ts

15
packages/nc-gui/components/smartsheet/grid/useColumnDrag.ts

@ -31,9 +31,10 @@ export const useColumnDrag = ({
const nextToColField = toColIndex < fields.value.length - 1 ? fields.value[toColIndex + 1] : null const nextToColField = toColIndex < fields.value.length - 1 ? fields.value[toColIndex + 1] : null
const nextToViewCol = nextToColField ? gridViewCols.value[nextToColField.id!] : null const nextToViewCol = nextToColField ? gridViewCols.value[nextToColField.id!] : null
const newOrder = nextToViewCol const lastCol = fields.value[fields.value.length - 1]
? toViewCol.order! + (nextToViewCol.order! - toViewCol.order!) / 2 const lastViewCol = gridViewCols.value[lastCol.id!]
: toBeReorderedViewCol.order! + 1
const newOrder = nextToViewCol ? toViewCol.order! + (nextToViewCol.order! - toViewCol.order!) / 2 : lastViewCol.order! + 1
const oldOrder = toBeReorderedViewCol.order const oldOrder = toBeReorderedViewCol.order
toBeReorderedViewCol.order = newOrder toBeReorderedViewCol.order = newOrder
@ -128,13 +129,13 @@ export const useColumnDrag = ({
const remInPx = parseFloat(getComputedStyle(document.documentElement).fontSize) const remInPx = parseFloat(getComputedStyle(document.documentElement).fontSize)
if (x > width.value * 0.5) { if (x < leftSidebarWidth.value + 1 * remInPx) {
setTimeout(() => { setTimeout(() => {
gridWrapper.value!.scrollLeft += 2.5 gridWrapper.value!.scrollLeft -= 2.5
}, 250) }, 250)
} else if (x < leftSidebarWidth.value + 10 * remInPx) { } else if (width.value - x - leftSidebarWidth.value < 15 * remInPx) {
setTimeout(() => { setTimeout(() => {
gridWrapper.value!.scrollLeft -= 2.5 gridWrapper.value!.scrollLeft += 2.5
}, 250) }, 250)
} }
} }

Loading…
Cancel
Save