Skip to content

Commit 8667ec7

Browse files
author
Cathy Siller
committed
new(wip): ie testing, js and styles not working
1 parent 00d6401 commit 8667ec7

File tree

5 files changed

+51
-21
lines changed

5 files changed

+51
-21
lines changed

docs/components/files/drop-zone-demo.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ if (document.getElementById('vue-dropZoneDemo')) {
33
el: '#vue-dropZoneDemo',
44
methods: {
55
onDrop: function (evt) {
6+
console.log('@drop');
67
// Prevent default behavior (Prevent file from being opened)
7-
evt.preventDefault();
8+
//evt.preventDefault();
89
if (evt.dataTransfer.items) {
910
// Use DataTransferItemList interface to access the file(s)
1011
for (var i = 0; i < evt.dataTransfer.items.length; i++) {
@@ -17,7 +18,7 @@ if (document.getElementById('vue-dropZoneDemo')) {
1718
} else {
1819
// Use DataTransfer interface to access the file(s)
1920
for (var i = 0; i < evt.dataTransfer.files.length; i++) {
20-
//alert('file drop successful! ' + evt.dataTransfer.files[i].name);
21+
alert('file drop successful! ' + evt.dataTransfer.files[i].name);
2122
}
2223
}
2324
},

docs/components/files/index.html

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
<section>
1616
<h2 id="drop-fence">Drop Fence</h2>
1717
<p class="hxSubBody">Added: v0.14.0</p>
18+
<p>A visual container that provides a visual affordance of drag-and-drop capabilities.</p>
19+
<p class="hxSubdued hxSubBody">
20+
<hx-icon type="info-circle"></hx-icon>
21+
Styles always removes padding.
22+
</p>
1823
<div class="example">
1924
<div>
2025
<div class="hxFence">
@@ -51,34 +56,42 @@ <h2 id="drop-fence">Drop Fence</h2>
5156
<section>
5257
<h2 id="drop-zone">Drop Zone</h2>
5358
<p class="hxSubBody">Added: v0.14.0</p>
59+
<p>A visual container that provides an overlay, marking the boundaries of where a user can drop a file.</p>
60+
<p class="hxSubdued hxSubBody">
61+
<hx-icon type="info-circle"></hx-icon>
62+
Styles always removes padding.
63+
</p>
5464
<div class="example" id="vue-dropZoneDemo">
5565
<div>
5666
<hx-drop-zone
5767
@drop.prevent="onDrop">
5868
<div class="hxFence">
5969
<hx-file-icon type="paperclip"></hx-file-icon>
60-
Drop files here or
61-
<hx-file-input
62-
class="hxTertiary"
63-
label="browse your files">
64-
<input type="file" />
65-
</hx-file-input>
70+
<p>
71+
Drop files here or
72+
<hx-file-input
73+
class="hxTertiary"
74+
label="browse your files">
75+
<input type="file" />
76+
</hx-file-input>
77+
</p>
6678
</div>
6779
</hx-drop-zone>
6880
</div>
6981

7082
<footer>
7183
{% code 'text' %}
72-
<hx-drop-zone
73-
@drop.prevent="onDrop">
84+
<hx-drop-zone>
7485
<div class="hxFence">
7586
<hx-file-icon type="paperclip"></hx-file-icon>
76-
Drop files here or
77-
<hx-file-input
78-
class="hxTertiary"
79-
label="browse your files">
80-
<input type="file" />
81-
</hx-file-input>
87+
<p>
88+
Drop files here or
89+
<hx-file-input
90+
class="hxTertiary"
91+
label="browse your files">
92+
<input type="file" />
93+
</hx-file-input>
94+
</p>
8295
</div>
8396
</hx-drop-zone>
8497
{% endcode %}

docs/elements/hx-drop-zone/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
<dd>
3535
<p>
3636
<i>(read-only)</i>
37+
Determines if file is dragged on the document or area.
3738
</p>
3839
</dd>
3940
{% endblock %}

src/helix-ui/elements/HXDropZoneElement.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,31 @@ export class HXDropZoneElement extends HXElement {
3535
return this.getAttribute('drag');
3636
}
3737

38-
/** @private */
38+
/**
39+
* @private
40+
* @see https://goo.gl/zaoexR
41+
*/
3942
_isFileDrag (evt) {
40-
return (evt.dataTransfer.types.indexOf('Files') !== -1);
43+
if (evt.dataTransfer.types) {
44+
if (evt.dataTransfer.types.indexOf) {
45+
return (evt.dataTransfer.types.indexOf('Files') !== -1);
46+
} else {
47+
return evt.dataTransfer.types.contains('Files');
48+
}
49+
} else {
50+
return false;
51+
}
4152
}
4253

4354
// #2 this gets called when the dragged item leaves the document (leaves to a child element or window altogether)
4455
/** @private */
4556
_onDocDragLeave () {
57+
window.clearTimeout(this._docDragLeaveTimeout);
4658
// callback must be an arrow function to preserve "this"
4759
this._docDragLeaveTimeout = window.setTimeout(() => {
4860
this._isDragging = false;
4961
this.removeAttribute('drag');
50-
}, 0);
62+
}, 250);
5163
}
5264

5365
// #1 this handler fires continuously as long as the user is dragging on the page
@@ -65,7 +77,8 @@ export class HXDropZoneElement extends HXElement {
6577
// #4 this gets called when the dragged item leaves the zone (leaves to a child element or zone altogether)
6678
/** @private */
6779
_onDragLeave (evt) {
68-
evt.preventDefault();
80+
//evt.preventDefault();
81+
window.clearTimeout(this._zoneDragLeaveTimeout);
6982
// callback must be an arrow function to preserve "this"
7083
this._zoneDragLeaveTimeout = window.setTimeout(() => {
7184
this._isZoneDragging = false;
@@ -76,19 +89,20 @@ export class HXDropZoneElement extends HXElement {
7689
// #3 this handler fires continuously as long as the user is dragging on the zone
7790
/** @private */
7891
_onDragOver (evt) {
92+
// needed for onDrop to work
7993
evt.preventDefault();
8094
if (!this._isZoneDragging) {
8195
this._isZoneDragging = true;
8296
if (this._isFileDrag(evt)) {
8397
this.setAttribute('drag', 'over');
8498
}
8599
}
100+
window.clearTimeout(this._docDragLeaveTimeout);
86101
window.clearTimeout(this._zoneDragLeaveTimeout);
87102
}
88103

89104
/** @private */
90105
_onDrop (evt) {
91-
//evt.preventDefault();
92106
this.removeAttribute('drag');
93107
this._isDragging = false;
94108
this._isZoneDragging = false;

src/helix-ui/styles/elements/hx-drop-zone.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
hx-drop-zone {
44
display: block;
5+
min-height: 0; // because IE
56
position: relative;
67

78
&::after {

0 commit comments

Comments
 (0)