Skip to content

Commit c683ab2

Browse files
authored
Create dropzone.md
1 parent 4bcac02 commit c683ab2

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
title: Dropzone
3+
---
4+
<Since version="4.4" issueNumber="MDL-80850" />
5+
6+
The use of the `core/dropzone` module provides a simplified developer experience for creating drop zones within Moodle.
7+
8+
The module attempts to ensure that accessibility requirements are met, including applying the correct styles and keyboard navigation.
9+
10+
Drop zones will trigger callbacks for common actions that occur within the drop zone for other code to listen to and react accordingly.
11+
12+
```js title="Example of creating a dropzone"
13+
import Dropzone from 'core/dropzone';
14+
15+
// Get the element that will be the dropzone.
16+
const dropZoneContainer = document.querySelector('#dropZoneId');
17+
// Create a new dropzone accepting only images.
18+
const dropZone = new Dropzone(
19+
dropZoneContainer,
20+
'image/*',
21+
function(files) {
22+
window.console.log(files);
23+
}
24+
);
25+
// Set the custom message for the dropzone. Otherwise, it will use the default message.
26+
dropZone.setLabel('Drop images here');
27+
// Initialising the dropzone.
28+
dropZone.init();
29+
```

0 commit comments

Comments
 (0)