0.0.1 • Published 3 years ago
@ngx-misc/dropzone-overlay v0.0.1
dropzone-overlay
Directive that will listen for drag & drop events on
Window object,
render custom overlay and provide and set associated
FormControl instance value with
dropped files.
This library was generated with Nx.
Installation
npm install @ngx-misc/dropzone-overlayUsage
Import the module:
import { ReactiveFormsModule } from '@angular/forms';
import { DropzoneOverlayModule } from '@ngx-misc/dropzone-overlay';
@NgModule({
imports: [
ReactiveFormsModule,
DropzoneOverlayModule
]
})In component template:
<input
[ngmDropzoneOverlay]="customDropzoneComponent"
[formControl]="fileControl"
[accept]="accept"
[multiple]="true"
type="file"
/>Where:
customDropzoneComponentis a component class that will be rendered in full screen overlay while files are dragged over the window,fileControlis aFormControlin host component,acceptis astringof acceptable file types,multipleis abooleanfor multiple file selection.
Because <input[type=file]> can be cumbersome to style, you can hide it and
use <button> element for interaction, like so:
<button (click)="fileInput.click()">Upload</button>
<input
#fileInput
[ngmDropzoneOverlay]="customDropzoneComponent"
[formControl]="fileControl"
[accept]="accept"
[multiple]="true"
type="file"
[hidden]="true"
/>Running unit tests
Run nx test dropzone-overlay to execute the unit tests.
0.0.1
3 years ago