docs: add JSDoc comments to DragDropService
This commit is contained in:
parent
a16cf8f374
commit
8557a2f7f0
1 changed files with 31 additions and 0 deletions
|
|
@ -10,6 +10,17 @@ export class DragDropService {
|
||||||
|
|
||||||
constructor() {}
|
constructor() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function is called when a drag event starts.
|
||||||
|
*
|
||||||
|
* It sets the `id` of the item being dragged to the `dataTransfer` object
|
||||||
|
* and emits an event indicating that the item has been moved from a certain
|
||||||
|
* status.
|
||||||
|
*
|
||||||
|
* @param event The drag event.
|
||||||
|
* @param id The id of the item being dragged.
|
||||||
|
* @param status The status of the item being dragged.
|
||||||
|
*/
|
||||||
startDragging(event: DragEvent, id: string | undefined, status: string) {
|
startDragging(event: DragEvent, id: string | undefined, status: string) {
|
||||||
if (id !== undefined) {
|
if (id !== undefined) {
|
||||||
event.dataTransfer?.setData('text/plain', id);
|
event.dataTransfer?.setData('text/plain', id);
|
||||||
|
|
@ -17,6 +28,16 @@ export class DragDropService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows a drop event to occur by preventing the default handling of the event.
|
||||||
|
*
|
||||||
|
* This function is called during the dragover event to indicate that the dragged
|
||||||
|
* item can be dropped in the current target. It prevents the default behavior and
|
||||||
|
* emits an event indicating that the item is being moved to a specified status.
|
||||||
|
*
|
||||||
|
* @param event The drag event.
|
||||||
|
* @param status The status to which the item is being moved.
|
||||||
|
*/
|
||||||
allowDrop(event: DragEvent, status: string) {
|
allowDrop(event: DragEvent, status: string) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const dataTransfer = event.dataTransfer;
|
const dataTransfer = event.dataTransfer;
|
||||||
|
|
@ -25,6 +46,16 @@ export class DragDropService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function is called when the user drops an item that was being dragged.
|
||||||
|
*
|
||||||
|
* It prevents the default behavior of the drop event and emits an event
|
||||||
|
* indicating that the item has been dropped. It also emits an event indicating
|
||||||
|
* that the item has been moved to a certain status.
|
||||||
|
*
|
||||||
|
* @param event The drag event.
|
||||||
|
* @param status The status to which the item is being moved.
|
||||||
|
*/
|
||||||
drop(event: DragEvent, status: string) {
|
drop(event: DragEvent, status: string) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const dataTransfer = event.dataTransfer;
|
const dataTransfer = event.dataTransfer;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue