mirror of
https://github.com/publiclab/image-sequencer.git
synced 2025-12-14 12:19:58 +01:00
drag drop added to demo (#121)
This commit is contained in:
@@ -40,6 +40,10 @@ h1 {
|
|||||||
color: #444;
|
color: #444;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.hover {
|
||||||
|
background: #eee;
|
||||||
|
}
|
||||||
|
|
||||||
#imageSelect input {
|
#imageSelect input {
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,9 +27,9 @@
|
|||||||
|
|
||||||
<header class="text-center">
|
<header class="text-center">
|
||||||
<h1>Image Sequencer</h1>
|
<h1>Image Sequencer</h1>
|
||||||
<h3>
|
<p>
|
||||||
<a href="https://github.com/publiclab/image-sequencer"><i class="fa fa-github"></i></a>
|
Open Source <a href="https://github.com/publiclab/image-sequencer"><i class="fa fa-github"></i></a> by <a href="https://publiclab.org">Public Lab</a>
|
||||||
</h3>
|
</p>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<div id="imageSelect">
|
<div id="imageSelect">
|
||||||
@@ -199,8 +199,13 @@
|
|||||||
sequencer.removeSteps(index).run();
|
sequencer.removeSteps(index).run();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#file').on('change',function(e){
|
function handleFile(e) {
|
||||||
var file = e.target.files[0];
|
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation(); // stops the browser from redirecting.
|
||||||
|
|
||||||
|
if (e.target && e.target.files) var file = e.target.files[0];
|
||||||
|
else var file = e.dataTransfer.files[0];
|
||||||
if(!file) return;
|
if(!file) return;
|
||||||
|
|
||||||
reader.onload = function(){
|
reader.onload = function(){
|
||||||
@@ -211,11 +216,31 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
reader.readAsDataURL(file);
|
reader.readAsDataURL(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#file').on('change', handleFile);
|
||||||
|
|
||||||
|
var select = $('#imageSelect');
|
||||||
|
|
||||||
|
select[0].addEventListener('drop', handleFile, false);
|
||||||
|
|
||||||
|
select.on('dragover', function(e) {
|
||||||
|
e.stopPropagation();
|
||||||
|
e.preventDefault();
|
||||||
|
e.dataTransfer.dropEffect = 'copy'; // Explicitly show this is a copy.
|
||||||
|
}, false);
|
||||||
|
|
||||||
|
select.on('dragenter', function(e) {
|
||||||
|
select.addClass('hover');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
select.on('dragleave', function(e) {
|
||||||
|
select.removeClass('hover');
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user