Blame view
src/app/component/import-vessels/import-vessels.directive.ts
856 Bytes
632c4ac2f import vessels |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
import {Directive, EventEmitter, HostBinding, HostListener, Output} from '@angular/core'; @Directive({ selector: '[appImportVessels]' }) export class ImportVesselsDirective { @HostBinding('class.fileover') fileOver: boolean; @Output() fileDropped = new EventEmitter<any>(); @HostListener('dragover', ['$event']) onDragOver(evt): void { evt.preventDefault(); evt.stopPropagation(); this.fileOver = true; } @HostListener('dragleave', ['$event']) public onDragLeave(evt): void { evt.preventDefault(); evt.stopPropagation(); this.fileOver = false; } @HostListener('drop', ['$event']) public ondrop(evt): void { evt.preventDefault(); evt.stopPropagation(); this.fileOver = false; const files = evt.dataTransfer.files; if (files.length > 0) { this.fileDropped.emit(files); } } } |