Skip to content

Commit

Permalink
start
Browse files Browse the repository at this point in the history
  • Loading branch information
jywarren committed May 9, 2018
1 parent 991e9bb commit 81e3956
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 52 deletions.
6 changes: 5 additions & 1 deletion examples/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,9 @@ window.onload = function() {
$('body').on('click', 'button.remove', ui.removeStepUi);

// image selection and drag/drop handling from examples/lib/imageSelection.js
setupFileHandling(sequencer);
sequencer.setInputStep({
dropZoneSelector: "#dropzone",
fileInputSelector: "#fileInput",
step: sequencer.images.image1.steps[0]
});
};
50 changes: 0 additions & 50 deletions examples/lib/imageSelection.js

This file was deleted.

4 changes: 3 additions & 1 deletion src/ImageSequencer.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,9 @@ ImageSequencer = function ImageSequencer(options) {
//other functions
log: log,
objTypeOf: objTypeOf,
copy: copy
copy: copy,

setInputStep: require('./ui/SetInputStep')(sequencer)
}

}
Expand Down
55 changes: 55 additions & 0 deletions src/ui/setInputStep.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
function setInputStepInit(_sequencer) {

return function setInputStep(options) {

var dropzone = $(options.dropZoneSelector);
var fileInput = $(fileInputId);
step = options.step;

onLoad = options.onLoad || function onFileReaderLoad() {
var loadStep = ;
step.output.src = reader.result;
_sequencer.run(0);
step.options.step.imgElement.src = reader.result;
}

var reader = new FileReader();

function handleFile(e) {

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;

var reader = new FileReader();

reader.onload = onLoad;

reader.readAsDataURL(file);
}

fileInput.on('change', handleFile);

dropzone[0].addEventListener('drop', handleFile, false);

dropzone.on('dragover', function onDragover(e) {
e.stopPropagation();
e.preventDefault();
e.dataTransfer.dropEffect = 'copy'; // Explicitly show this is a copy.
}, false);

dropzone.on('dragenter', function onDragEnter(e) {
dropzone.addClass('hover');
});

dropzone.on('dragleave', function onDragLeave(e) {
dropzone.removeClass('hover');
});

}

}
module.exports = setInputStepInit;

0 comments on commit 81e3956

Please sign in to comment.