Dropzone extends KompElement

A container that handles drag/drop events

Example

JS
new Dropzone({
    onFileDrop: console.log,
    content: {
        content: 'Drag Something Here',
        class: 'border-2px border-dashed'
    }
})

Constructor

new Dropzone(options)
options : Object optional
overlay : function | HTMLElement | Object optional

layer to render over dropzone when drag happens on window

onFileDrop : function optional

callback for drop action, receives File

enabled : boolean optional

setup events

content : string | HTMLElement | Array | Object optional

content to append to element. Passed to Dolla's content

Instance Properties

Attributes settable via constructor options

Methods overridable via constructor options

Methods to auto-bind to this

Event names that can be bound via onEventName constructor options

CSS injected once per component via adoptedStyleSheets

Attributes to observe for changes. Triggers changed(attribute, was, now) and [attribute]Changed(was, now) callbacks.

Instance Methods

Listen for events on another element, automatically cleaned up when this component disconnects

Parameters

element : HTMLElement

element to listen on

eventType : string

event type

args : *

additional arguments passed to addEventListener

Called every time an observed attribute changes. Attribute must be listed in static watch.

Parameters

attribute : string

the attribute that changed

was : *

previous value

now : *

new value

Called when element is connected to the DOM

Tear down drag/drop event listeners

Called when element is disconnected from the DOM

Set up drag/drop event listeners

Called once per instantiation, but only after element is connected to the DOM

Remove element. Fires beforeRemove, calls optional callback, removes from DOM, then fires afterRemove.

Parameters

callback : function optional

async callback called between beforeRemove and afterRemove

Returns

Trigger an event on this element

Parameters

eventName : string

event name to trigger

args : *

additional arguments

Events

Fired after the element is connected to the DOM and initialized

Fired after the element is disconnected from the DOM

Fired after the element is removed

Fired before the element is connected to the DOM

Fired before the element is disconnected from the DOM

Fired before the element is removed

Fired for each file dropped onto the dropzone