Interface DataTransfer
dropEffect: "link" | "copy" | "none" | "move";
effectAllowed:
| "link"
| "copy"
| "none"
| "move"
| "copyLink"
| "copyMove"
| "linkMove"
| "all"
| "uninitialized";
files: FileList;
items: DataTransferItemList;
types: readonly string[];
clearData(format?: string): void;
getData(format: string): string;
setData(format: string, data: string): void;
setDragImage(image: Element, x: number, y: number): void;
}
Index
Properties
Methods
Properties
dropEffect
The DataTransfer.dropEffect property controls the feedback (typically visual) the user is given during a drag and drop operation.
effectAllowed
| "link"
| "copy"
| "none"
| "move"
| "copyLink"
| "copyMove"
| "linkMove"
| "all"
| "uninitialized"
The DataTransfer.effectAllowed property specifies the effect that is allowed for a drag operation.
Readonlyfiles
The files read-only property of DataTransfer objects is a list of the files in the drag operation.
Readonlyitems
The read-only items property of the DataTransfer interface is a A DataTransferItemList object containing DataTransferItem objects representing the items being dragged in a drag operation, one list item for each object being dragged.
Readonlytypes
The DataTransfer.types read-only property returns the available types that exist in the DataTransfer.items.
Methods
clearData
The
DataTransfer.clearData()method removes the drag operation's drag data for the given type.Parameters
Optionalformat: string
Returns void
getData
The
DataTransfer.getData()method retrieves drag data (as a string) for the specified type.Parameters
- format: string
Returns string
setData
The
DataTransfer.setData()method sets the drag operation's drag data to the specified data and type.Parameters
- format: string
- data: string
Returns void
setDragImage
When a drag occurs, a translucent image is generated from the drag target (the element the HTMLElement/dragstart_event event is fired at), and follows the mouse pointer during the drag.
Parameters
- image: Element
- x: number
- y: number
Returns void
The
DataTransferobject is used to hold any data transferred between contexts, such as a drag and drop operation, or clipboard read/write.MDN Reference