Skip to content

Commit 0385829

Browse files
committed
refactor: make condition a variable.
1 parent 0ca893c commit 0385829

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

apps/calendar/src/components/events/horizontalEvent.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { dndSelector, optionsSelector, viewSelector } from '@src/selectors';
1616
import { DraggingState } from '@src/slices/dnd';
1717
import { isSameDate } from '@src/time/datetime';
1818
import { passConditionalProp } from '@src/utils/preact';
19-
import { isNil } from '@src/utils/type';
19+
import { isPresent } from '@src/utils/type';
2020

2121
import type { CalendarColor } from '@t/options';
2222

@@ -144,8 +144,9 @@ export function HorizontalEvent({
144144
const eventContainerRef = useRef<HTMLDivElement>(null);
145145

146146
const { isReadOnly, id, calendarId } = uiModel.model;
147-
const isDraggableEvent =
148-
!isReadOnlyCalendar && !isReadOnly && isNil(resizingWidth) && isNil(movingLeft);
147+
148+
const isDraggingGuideEvent = isPresent(resizingWidth) || isPresent(movingLeft);
149+
const isDraggableEvent = !isReadOnlyCalendar && !isReadOnly && !isDraggingGuideEvent;
149150

150151
const startDragEvent = (className: string) => {
151152
setDraggingEventUIModel(uiModel);
@@ -160,8 +161,7 @@ export function HorizontalEvent({
160161
if (
161162
draggingState === DraggingState.DRAGGING &&
162163
draggingEventUIModel?.cid() === uiModel.cid() &&
163-
isNil(resizingWidth) &&
164-
isNil(movingLeft)
164+
!isDraggingGuideEvent
165165
) {
166166
setIsDraggingTarget(true);
167167
} else {
@@ -170,7 +170,7 @@ export function HorizontalEvent({
170170
});
171171

172172
useEffect(() => {
173-
if (isNil(resizingWidth) && isNil(movingLeft)) {
173+
if (!isDraggingGuideEvent) {
174174
eventBus.fire('afterRenderEvent', uiModel.model.toEventObject());
175175
}
176176
// This effect is only for the first render.

0 commit comments

Comments
 (0)