mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-22 19:11:33 +03:00
Planner: fixed sticking to events when resizing (#6648)
This commit is contained in:
parent
7b98fbc3d2
commit
2cc5309d64
@ -546,7 +546,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
const getExactly = (e: MouseEvent, correction: boolean = false): number => {
|
const getExactly = (e: MouseEvent, correction: boolean = false): number => {
|
||||||
return Math.round((e.offsetY * 60) / cellHeight) - (correction ? 15 : 0)
|
const exactly = Math.round((e.offsetY * 60) / cellHeight) - (correction ? 15 : 0)
|
||||||
|
return exactly <= 0 ? 0 : exactly
|
||||||
}
|
}
|
||||||
|
|
||||||
const getStickyMinutes = (
|
const getStickyMinutes = (
|
||||||
@ -566,22 +567,22 @@
|
|||||||
const target = new Date(day).setHours(hour, exactly, 0, 0)
|
const target = new Date(day).setHours(hour, exactly, 0, 0)
|
||||||
const events = newEvents.filter((ev) => ev._id !== skipId && !ev.allDay)
|
const events = newEvents.filter((ev) => ev._id !== skipId && !ev.allDay)
|
||||||
if (events.length > 0) {
|
if (events.length > 0) {
|
||||||
const minutes: number[] = []
|
const dates: Array<{ date: number, hours: number, mins: number }> = []
|
||||||
for (const ev of events) {
|
for (const ev of events) {
|
||||||
if (ev.date >= min && ev.date <= max) {
|
if (ev.date >= min && ev.date <= max) {
|
||||||
minutes.push(convertToTime(ev.date).mins)
|
dates.push({ date: ev.date, ...convertToTime(ev.date) })
|
||||||
}
|
}
|
||||||
if (ev.dueDate >= min && ev.dueDate <= max) {
|
if (ev.dueDate >= min && ev.dueDate <= max) {
|
||||||
minutes.push(convertToTime(ev.dueDate).mins)
|
dates.push({ date: ev.date, ...convertToTime(ev.dueDate) })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (minutes.length > 0) {
|
if (dates.length > 0) {
|
||||||
let nearest = minutes[0]
|
let nearest = dates[0]
|
||||||
for (let index = 1; index < minutes.length; index++) {
|
for (let index = 1; index < dates.length; index++) {
|
||||||
const minute = minutes[index]
|
const date = dates[index]
|
||||||
if (Math.abs(minute - target) < Math.abs(nearest - target)) nearest = minute
|
if (Math.abs(date.date - target) < Math.abs(nearest.date - target)) nearest = date
|
||||||
}
|
}
|
||||||
return nearest
|
return nearest.hours > hour && nearest.mins === 0 ? 60 : nearest.mins
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1014,9 +1015,11 @@
|
|||||||
{@const rect = getRect(event)}
|
{@const rect = getRect(event)}
|
||||||
{@const ev = events.find((p) => p._id === event._id)}
|
{@const ev = events.find((p) => p._id === event._id)}
|
||||||
{#if ev}
|
{#if ev}
|
||||||
|
{@const pointerEventsNone = !!resizeId && resizeId !== ev._id}
|
||||||
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
||||||
<div
|
<div
|
||||||
class="calendar-element"
|
class="calendar-element"
|
||||||
|
class:pointer-events-none={!!resizeId}
|
||||||
class:past={rect.visibility === 0}
|
class:past={rect.visibility === 0}
|
||||||
style:top={`${rect.top}px`}
|
style:top={`${rect.top}px`}
|
||||||
style:bottom={`${rect.bottom}px`}
|
style:bottom={`${rect.bottom}px`}
|
||||||
@ -1032,6 +1035,7 @@
|
|||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="calendar-element-start"
|
class="calendar-element-start"
|
||||||
|
class:pointer-events-none={pointerEventsNone}
|
||||||
class:allowed={!resizeId && !dragId && !clearCells}
|
class:allowed={!resizeId && !dragId && !clearCells}
|
||||||
class:hovered={resizeId === ev._id && directionResize === 'top'}
|
class:hovered={resizeId === ev._id && directionResize === 'top'}
|
||||||
on:mousedown={(e) => {
|
on:mousedown={(e) => {
|
||||||
@ -1043,6 +1047,7 @@
|
|||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
class="calendar-element-end"
|
class="calendar-element-end"
|
||||||
|
class:pointer-events-none={pointerEventsNone}
|
||||||
class:allowed={!resizeId && !dragId && !clearCells}
|
class:allowed={!resizeId && !dragId && !clearCells}
|
||||||
class:hovered={resizeId === ev._id && directionResize === 'bottom'}
|
class:hovered={resizeId === ev._id && directionResize === 'bottom'}
|
||||||
on:mousedown={(e) => {
|
on:mousedown={(e) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user