# @ebcoder/ngx-filequake

> This Angular 5+ directive can be used on any element (host) to create a "Drag N' Drop" zone for multi-file upload. Clicking the zone can also launch the browser's default FileOpen dialog based on configuration.

Latest version **0.0.3** (published 2018-03-28) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @ebcoder/ngx-filequake
pnpm add @ebcoder/ngx-filequake
yarn add @ebcoder/ngx-filequake
bun add @ebcoder/ngx-filequake
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2018-03-28 |
| First published | 2018-03-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 54.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Edward Boyle |
| Maintainers | ebcoder |
| Keywords | angular, angular5, directive, drag, drop, drag and drop, file upload, dropzone |

## Links

- npm: https://www.npmjs.com/package/@ebcoder/ngx-filequake
- Repository: https://github.com/edwardboyle/ngx-filequake
- Homepage: https://github.com/edwardboyle/ngx-filequake#readme
- Issues: https://github.com/edwardboyle/ngx-filequake/issues
- npm.io page: https://npm.io/package/@ebcoder/ngx-filequake

## Dependencies (1)

- [tslib](https://npm.io/package/tslib.md) ^1.7.1

## Recent versions

- 0.0.3 (latest) — 2018-03-28
- 0.0.2 — 2018-03-27

## README

# ngx-filequake

This Angular directive can be used on any element (host) to create a "Drag N' Drop" zone for multi-file upload. Clicking the zone can also launch the browser's default FileOpen dialog based on configuration.

![We see the drag and drop and the event fire when dropped](https://media.giphy.com/media/QK47wvTS29288OdkrD/giphy.gif)

## Installing

Using Yarn

```console
yarn add @ebcoder/ngx-filequake
```

Using NPM

```console
npm install @ebcoder/ngx-filequake
```

## Basic Usage

in your app.module.ts

```typescript
import {NgxFilequakeModule} from '@ebcoder/ngx-filequake';

//.....

@NgModule({
  imports: [
    NgxFilequakeModule
  ]
  //...
```

Use it in your template

```html
<div
ngxFilequake
[zoneonly]="true"
[canclick]="true"
dialogaccept="image/*"
(filesChanged)="doSomething($event)">
</div>
```

## Inputs

`[zoneonly]="boolean"` *(default: `false`)*

If true the directive will prevent any dragover and drop event outside of the directive. If false, default behavior is observed.

`[canclick]="boolean"` *(default: `true`)*

If `true` the directive will generate an invisible file input as this is the only known way to provide a file dialog.
The directive will create the element and use CSS to hide the element. Clicking on the decorated element will invoke the click event on the file input and pass the files selected back to the directive and then invoking `filesChanged`

`dialogaccept="string"` *(default: `''`)*

This string is simply passed to the dynamically created file input's `accept` value. See: [accept Attribute](https://www.w3schools.com/tags/att_input_accept.asp).

## Events

`filesChanged`

An event that is fired when the files are select or dropped on the host. Emits `FileList`

## CSS

`.dragover`

dragover and dragleave will toggle the ".dragover" CSS class on the host. This handy CSS class that can be used for providing some type of user interface changes so the user knows they can drop the files.  *In the example provided below; we use this to color the drop zone green when the user can drop files.*

## Example

Template

```html
<div
ngxFilequake
[zoneonly]="true"
[canclick]="true"
dialogaccept="image/*"
(filesChanged)="doSomething($event)"
class="dropzone">
</div>
```

SCSS

```scss
/*
Style your element
This creates a 90px wide bar on the right of the screen.
*/
.dropzone{
  position: fixed;
  right: 0;
  top: 0;
  width: 90px;
  height: 100%;
  background-color: rgb(230, 230, 230);
  border-left: 1px solid rgb(209, 209, 209);
  cursor: pointer;
/*
 Makes use of the "dragover" class added by the directive.
 We use it to change background of the host to green
 to indicate to the user they can drop.
*/
  &.dragover {
    background-color: rgb(108, 255, 108);
  }
}
```

TypeScript

```typescript
doSomething(fileList : FileList){
  console.log(fileList.length);
}

---
_Source: https://npm.io/package/@ebcoder/ngx-filequake · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
