Handling drag events. Due to the limitation of not being able to call JavaScript functions directly in elm, full drag and drop API cannot be supported.
However, most of the time we just need to be able to drop some files
from the file system to the web page.
By providing the dragover, and drop events,
this module enables such use case.
Of course, the file retrieved in the form of a
Json.Decode.Value would still have to be
sent through ports if further processing is needed
that cannot be done directly using the Value.
Hold the data being dragged during a drag and drop operation. This corresponds to JavaScript DataTransfer.
The files attribute holds the list of files being dragged.
The types attribute contains a list of strings providing
the different formats of objects being dragged.
The dropEffect attribute provides feedback on the selected effect
for the current drag and drop operation. It can be one of:
"none": the item may not be dropped"copy": a copy of the source item is made at the new location"move": the item is moved to a new location"link": a link to the source is somehow established at the new locationBeware that contrary to JavaScript, you have no way of modifying
dropEffect in elm. This is provided purely for information as read only,
like any other elm value.
The effectAllowed property is not provided since it has
no use in the context of elm.
The items property is not provided by lack of compatibility.
A file object is a specific kind of blob.
Its raw JavaScript value is hold in the data attribute
in the form of a Json.Decode.Value.
This corresponds to a JavaScript File
name: name of the file, without the path for security reasonstypeMIME: MIME type of the filesize: size of the file in bytesRemark: providing these properties as attributes in an elm record
is the easiest way of bringing this File API to elm.
Of course if at some point the File API is supported in elm,
this would be changed to the supported version.
Listen to dragover events.
Listen to drop events.
Listen to dragleave events.
Personalize your drag events with chosen html options.
Drag.Event default decoder.
It is provided in case you would like to extend it.
DataTransfer decoder.
It is provided in case you would like to extend it.
Turn a personalized file decoder into a List decoder.
File decoder.
It is provided in case you would like to extend it.
Type that get returned by a browser drag event. It corresponds to a JavaScript DragEvent.
Since a
DragEventinherits fromMouseEvent, all mouse event related properties are provided in themouseEventattribute of typeMouse.Event. Please refer to theMousemodule for more information on this value.