You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

file-drop-element

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

file-drop-element

File Drop Custom Element

0.0.6
Source
npmnpm
Version published
Weekly downloads
1.1K
-26.21%
Maintainers
1
Weekly downloads
 
Created
Source

file-drop Custom Element

The file drop custom element is a simple Custom Element that accepts File objects being dropped on it and fires a dedicated event onfiledrop when a successful drop occurs.

Installation

npm i file-drop-element

Usage

Directly as a module

Copy from node_modules in to a local directory.

<script src='file-drop.mjs' type='module'></script>

<file-drop>

  Drop file here

</file-drop>

Directly as a UMD, for non-ES6 Module supporting browsers

<script src='file-drop.umd.js'></script>

<file-drop>

  Drop file here

</file-drop>

Only allow certain files to be dropped on the element.

The element will accept any drop event that has the .dataTransfer object populated with any file. If you want to control the types of files that can be dropped on to the element, use the same syntax that <input> elements use when the accept attribute is set, that is:

  • <file-drop> - any file
  • <file-drop accept='image/*'> - all images
  • <file-drop accept='image/png'> - only Images that have the MIME-type of a PNG.

Styling

The element an inline display element and it can be controlled like any normal element. The element does not use Shadow DOM so there are no internal elements to style.

The element will add two classes drop-valid and drop-invalid to the element depending on the mime-type of the file that is currently being dragged over the element.

<style>

file-drop.drop-valid {
  background-color: green;
}

file-drop.drop-invalid {
  background-color: red;
}

</style>

Keywords

custom

FAQs

Package last updated on 15 Oct 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.