AnimationTool/app/page.ts

55 lines
1.4 KiB
TypeScript
Raw Normal View History

2019-09-25 03:16:07 +00:00
import { FileHandler } from './file_handler';
import { FrameHandler } from './frame_handler';
2019-09-25 00:01:54 +00:00
export class Page {
2019-09-25 03:16:07 +00:00
private static handleDragOver(evt: DragEvent) {
if (evt !== null) {
evt.stopPropagation();
evt.preventDefault();
evt.dataTransfer!.dropEffect = 'copy'; // Explicitly show this is a copy.
}
}
private filenames: string[] = [];
2019-09-25 00:01:54 +00:00
public Load() {
2019-09-25 03:16:07 +00:00
// const fileHandler = new FileHandler('dropZone', 'output', this.filenames);
const frameHandler = new FrameHandler(document.getElementById('currentImage') as HTMLElement);
const dropZone = document.getElementById('dropZone') as HTMLElement;
const output = document.getElementById('output') as HTMLElement;
dropZone.addEventListener('dragover', Page.handleDragOver, false);
dropZone.addEventListener('drop', this.handleFileSelect, false);
2019-09-25 00:42:35 +00:00
2019-09-25 03:16:07 +00:00
const keyDown = (event: KeyboardEvent) => {
switch (event.keyCode) {
case 39: {
// right_arrow
console.log('next frame action');
frameHandler.AdvanceFrames(1);
break;
}
case 37: {
// left arrow
console.log('previous frame action');
frameHandler.AdvanceFrames(-1);
break;
}
}
2019-09-25 00:42:35 +00:00
};
2019-09-25 03:16:07 +00:00
document.addEventListener('keydown', keyDown);
2019-09-25 00:01:54 +00:00
}
2019-09-25 03:16:07 +00:00
private handleFileSelect = (event: any) => {
event.stopPropagation();
event.preventDefault();
FileHandler.ProcessImages(event.target.result);
console.log('files: ' + this.filenames.length);
};
2019-09-25 00:01:54 +00:00
}