Browse Source

fix(nc-gui): drag drop not smooth in month view

pull/7611/head
DarkPhoenix2704 7 months ago
parent
commit
f0ccd82e36
  1. 16
      packages/nc-gui/components/smartsheet/calendar/MonthView.vue
  2. 6
      packages/nc-gui/components/smartsheet/calendar/WeekView/DateTimeField.vue

16
packages/nc-gui/components/smartsheet/calendar/MonthView.vue

@ -445,13 +445,11 @@ const onResizeStart = (direction: 'right' | 'left', event: MouseEvent, record: R
}
const stopDrag = (event: MouseEvent) => {
if (!isUIAllowed('dataEdit') || !dragRecord.value) return
if (!isUIAllowed('dataEdit') || !dragRecord.value || !isDragging.value) return
event.preventDefault()
clearTimeout(dragTimeout.value)
if (!isDragging.value) return
dragElement.value!.style.boxShadow = 'none'
const { top, height, width, left } = calendarGridContainer.value.getBoundingClientRect()
@ -547,6 +545,8 @@ const dragStart = (event: MouseEvent, record: Row) => {
isDragging.value = false
dragTimeout.value = setTimeout(() => {
isDragging.value = true
while (!target.classList.contains('draggable-record')) {
target = target.parentElement as HTMLElement
}
@ -568,7 +568,7 @@ const dragStart = (event: MouseEvent, record: Row) => {
document.addEventListener('mousemove', onDrag)
document.addEventListener('mouseup', stopDrag)
}, 500)
}, 200)
const onMouseUp = () => {
clearTimeout(dragTimeout.value)
@ -685,14 +685,6 @@ const isDateSelected = (date: Date) => {
if (!selectedDate.value) return false
return dayjs(date).isSame(selectedDate.value, 'day')
}
onMounted(() => {
document.addEventListener('mouseup', stopDrag)
})
onBeforeUnmount(() => {
document.removeEventListener('mouseup', stopDrag)
})
</script>
<template>

6
packages/nc-gui/components/smartsheet/calendar/WeekView/DateTimeField.vue

@ -436,12 +436,12 @@ const onDrag = (event: MouseEvent) => {
}
const stopDrag = (event: MouseEvent) => {
event.preventDefault()
clearTimeout(dragTimeout.value!)
if (!isUIAllowed('dataEdit')) return
if (!isDragging.value || !container.value || !dragRecord.value) return
event.preventDefault()
clearTimeout(dragTimeout.value!)
const { width, left, top } = container.value.getBoundingClientRect()
const { scrollHeight } = container.value

Loading…
Cancel
Save