add condition to check if active

fixes #6840
"setMap" registers listeners to dropArea, but it doesn't check whether "active" is true or false. Simply add condition to check "active".
This commit is contained in:
Chase(Seul-gi Choi)
2017-05-23 10:48:12 +09:00
committed by GitHub
parent e272eced94
commit 661410a96e
+6
View File
@@ -65,6 +65,8 @@ ol.inherits(ol.interaction.DragAndDrop, ol.interaction.Interaction);
* @private * @private
*/ */
ol.interaction.DragAndDrop.handleDrop_ = function(event) { ol.interaction.DragAndDrop.handleDrop_ = function(event) {
var active = this.getActive();
if (active) {
var files = event.dataTransfer.files; var files = event.dataTransfer.files;
var i, ii, file; var i, ii, file;
for (i = 0, ii = files.length; i < ii; ++i) { for (i = 0, ii = files.length; i < ii; ++i) {
@@ -74,6 +76,7 @@ ol.interaction.DragAndDrop.handleDrop_ = function(event) {
this.handleResult_.bind(this, file)); this.handleResult_.bind(this, file));
reader.readAsText(file); reader.readAsText(file);
} }
}
}; };
@@ -82,9 +85,12 @@ ol.interaction.DragAndDrop.handleDrop_ = function(event) {
* @private * @private
*/ */
ol.interaction.DragAndDrop.handleStop_ = function(event) { ol.interaction.DragAndDrop.handleStop_ = function(event) {
var active = this.getActive();
if (active) {
event.stopPropagation(); event.stopPropagation();
event.preventDefault(); event.preventDefault();
event.dataTransfer.dropEffect = 'copy'; event.dataTransfer.dropEffect = 'copy';
}
}; };