Skip to content

onDrop

Hears an element of the page (makeDraggable) dropped on a droppable calendar.

Type(drop: DropInfo) => void
Defaultnot set
Live update (update())Yes
Declared inpackages/dom/src/settings.ts

It receives { data, date, allDay, resourceId, element }: your element’s data (a patient’s id), the moment in the calendar’s zone or the day it was put on, the resource of the column or row (or the element’s own), and the element itself. It is called once the event is made, then onEventReceive — not when the drop is refused — or, for a draggable made with create: false, alone, no event made: create what you want yourself. Take the card off your waiting list here; the event itself comes to onEventReceive.

In Angular it is dropped, not drop (which would also hear the browser’s own drop event); Vue follows for consistency. An event dragged from another calendar is not a drop: it comes to onEventReceive.

import { createCalendar } from '@dzcalendar/dom';
import { makeDraggable } from '@dzcalendar/dom/drag';
const card = document.getElementById('patient-42')!;
makeDraggable(card, { event: { title: 'Consultation', duration: { minutes: 30 } }, data: { patientId: 42 } });
createCalendar(element, {
timeZone: 'Europe/Paris',
droppable: true,
// Booked: off the waiting list.
onDrop: (drop) => drop.element?.remove(),
});

In the frameworks it is an output: Angular’s (dropped), React’s onDrop, Vue’s @dropped.