File tree Expand file tree Collapse file tree 5 files changed +50
-33
lines changed Expand file tree Collapse file tree 5 files changed +50
-33
lines changed Original file line number Diff line number Diff line change @@ -2,8 +2,24 @@ if (document.getElementById('vue-dropZoneDemo')) {
22 new Vue ( {
33 el : '#vue-dropZoneDemo' ,
44 methods : {
5- onDrop : function ( ) {
6- alert ( 'Unicorn pigeon puppy pop rainbows delight social pop!' ) ;
5+ onDrop : function ( evt ) {
6+ // Prevent default behavior (Prevent file from being opened)
7+ evt . preventDefault ( ) ;
8+ if ( evt . dataTransfer . items ) {
9+ // Use DataTransferItemList interface to access the file(s)
10+ for ( var i = 0 ; i < evt . dataTransfer . items . length ; i ++ ) {
11+ // If dropped items aren't files, reject them
12+ if ( evt . dataTransfer . items [ i ] . kind === 'file' ) {
13+ var file = evt . dataTransfer . items [ i ] . getAsFile ( ) ;
14+ alert ( 'File Drop Successful! ' + file . name ) ;
15+ }
16+ }
17+ } else {
18+ // Use DataTransfer interface to access the file(s)
19+ for ( var i = 0 ; i < evt . dataTransfer . files . length ; i ++ ) {
20+ //alert('file drop successful! ' + evt.dataTransfer.files[i].name);
21+ }
22+ }
723 } ,
824 } ,
925 } ) ;
Original file line number Diff line number Diff line change @@ -19,25 +19,29 @@ <h2 id="drop-fence">Drop Fence</h2>
1919 < div >
2020 < div class ="hxFence ">
2121 < hx-file-icon type ="paperclip "> </ hx-file-icon >
22- Drop a file here or
23- < hx-file-input
24- class ="hxTertiary "
25- label ="browse your files ">
26- < input type ="file " />
27- </ hx-file-input >
22+ < p >
23+ Drop files here or
24+ < hx-file-input
25+ class ="hxTertiary "
26+ label ="browse your files ">
27+ < input type ="file " />
28+ </ hx-file-input >
29+ </ p >
2830 </ div >
2931 </ div >
3032
3133 < footer >
3234 {% code 'text' %}
3335 < div class ="hxFence ">
3436 < hx-file-icon type ="paperclip "> </ hx-file-icon >
35- Drop a file here or
36- < hx-file-input
37- class ="hxTertiary "
38- label ="browse your files ">
39- < input type ="file " />
40- </ hx-file-input >
37+ < p >
38+ Drop files here or
39+ < hx-file-input
40+ class ="hxTertiary "
41+ label ="browse your files ">
42+ < input type ="file " />
43+ </ hx-file-input >
44+ </ p >
4145 </ div >
4246 {% endcode %}
4347 </ footer >
@@ -50,10 +54,10 @@ <h2 id="drop-zone">Drop Zone</h2>
5054 < div class ="example " id ="vue-dropZoneDemo ">
5155 < div >
5256 < hx-drop-zone
53- @drop ="onDrop ">
57+ @drop.prevent ="onDrop ">
5458 < div class ="hxFence ">
5559 < hx-file-icon type ="paperclip "> </ hx-file-icon >
56- Drop a file here or
60+ Drop files here or
5761 < hx-file-input
5862 class ="hxTertiary "
5963 label ="browse your files ">
@@ -65,10 +69,11 @@ <h2 id="drop-zone">Drop Zone</h2>
6569
6670 < footer >
6771 {% code 'text' %}
68- < hx-drop-zone >
72+ < hx-drop-zone
73+ @drop.prevent ="onDrop ">
6974 < div class ="hxFence ">
7075 < hx-file-icon type ="paperclip "> </ hx-file-icon >
71- Drop a file here or
76+ Drop files here or
7277 < hx-file-input
7378 class ="hxTertiary "
7479 label ="browse your files ">
Original file line number Diff line number Diff line change 11---
22title: < hx-drop-zone >
3- minver: 0.13 .0
3+ minver: 0.14 .0
44also:
55 components/files: Files
66---
2727 </ div >
2828 </ dl >
2929 </ section >
30-
31- < section >
32- < h2 id ="methods "> Methods</ h2 >
33- </ section >
34- {% endblock %}
35-
36- {% block attributes %}
3730{% endblock %}
3831
3932{% block properties %}
33+ < dt > drag {String}</ dt >
34+ < dd >
35+ < p >
36+ < i > (read-only)</ i >
37+ </ p >
38+ </ dd >
4039{% endblock %}
Original file line number Diff line number Diff line change @@ -86,18 +86,11 @@ export class HXDropZoneElement extends HXElement {
8686 window . clearTimeout ( this . _zoneDragLeaveTimeout ) ;
8787 }
8888
89- drop ( ) {
90- if ( this . $emit ( 'drop' ) ) {
91- this . remove ( ) ;
92- }
93- }
94-
9589 /** @private */
9690 _onDrop ( evt ) {
9791 //evt.preventDefault();
9892 this . removeAttribute ( 'drag' ) ;
9993 this . _isDragging = false ;
10094 this . _isZoneDragging = false ;
101- this . drop ( ) ;
10295 }
10396}
Original file line number Diff line number Diff line change @@ -42,4 +42,8 @@ hx-drop-zone {
4242 hx- file- icon {
4343 display : block ;
4444 }
45+
46+ > * + * {
47+ margin-top : 0.5rem ;
48+ }
4549}
You can’t perform that action at this time.
0 commit comments