Skip to content

Commit 489c602

Browse files
committed
Count active drops in dropzones demo
1 parent b22d116 commit 489c602

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

demo/js/dropzones.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,27 @@
5757
}
5858
})
5959
.on('dropactivate', function (event) {
60-
addClass(event.target, '-drop-possible');
61-
event.target.textContent = 'Drop me here!';
60+
var active = event.target.getAttribute('active')|0;
6261

62+
// change style if it was previously not active
63+
if (active === 0) {
64+
addClass(event.target, '-drop-possible');
65+
event.target.textContent = 'Drop me here!';
66+
}
67+
68+
event.target.setAttribute('active', active + 1);
6369
})
6470
.on('dropdeactivate', function (event) {
65-
removeClass(event.target, '-drop-possible');
66-
event.target.textContent = 'Dropzone';
71+
var active = event.target.getAttribute('active')|0;
72+
73+
// change style if it was previously active
74+
// but will no longer be active
75+
if (active === 1) {
76+
removeClass(event.target, '-drop-possible');
77+
event.target.textContent = 'Dropzone';
78+
}
79+
80+
event.target.setAttribute('active', active - 1);
6781
})
6882
.on('dragenter', function (event) {
6983
addClass(event.target, '-drop-over');

0 commit comments

Comments
 (0)