Skip to content

Commit

Permalink
added drag listener and handler
Browse files Browse the repository at this point in the history
  • Loading branch information
gmsa committed Jun 14, 2016
1 parent 7fcf864 commit 4f86a8e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions vue.drag-and-drop.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
params: [
'drag-and-drop',
'drag-start',
'drag',
'drag-over',
'drag-enter',
'drag-leave',
Expand Down Expand Up @@ -51,6 +52,11 @@
}
e.target.classList.remove('drag-enter');
}.bind(this);
this.handleDrag = function(e) {
if (typeof(this.vm[this.params.drag]) === 'function') {
this.vm[this.params.drag].call(this, e.target);
}
}.bind(this);
this.handleDragEnd = function(e) {
e.target.classList.remove('dragging', 'drag-over', 'drag-enter');
if (typeof(this.vm[this.params.dragEnd]) === 'function') {
Expand All @@ -76,6 +82,7 @@
this.el.addEventListener('dragstart', this.handleDragStart, false);
this.el.addEventListener('dragenter', this.handleDragEnter, false);
this.el.addEventListener('dragover', this.handleDragOver, false);
this.el.addEventListener('drag', this.handleDrag, false);
this.el.addEventListener('dragleave', this.handleDragLeave, false);
this.el.addEventListener('drop', this.handleDrop, false);
this.el.addEventListener('dragend', this.handleDragEnd, false);
Expand Down

0 comments on commit 4f86a8e

Please sign in to comment.