Giter Club home page Giter Club logo

droplet's Introduction

Droplet

Droplet is an AJAX uploader supporting drag-and-drop, with a progress bar and an image resizer. It's known to be compatible with Firefox and Chrome, and possibly other browsers.

To use, add the javascript and CSS in the page, then set Droplet.form to your upload form (the form is used as a fallback if Droplet is incompatible, and other form widgets can also be used), and Droplet.zones to an array of elements that will accept dropped files:

Droplet.form = document.getElementById('form');
// this line isn't needed if the whole page should accept dropped files
Droplet.zones = [document.getElementById('zone')];

To do something on completion of upload, set an uploadComplete callback:

Droplet.uploadComplete = function (req) {
	document.getElementById('output').textContent = req.responseText;
};

Image Resizer

Droplet can reduce PNG or JPEG files before upload to save upload time. To use this feature, set a maximum width and height for images. If you set a threshold, images won't be scaled if the size of the reduction is greater than the threshold (in this case if they're already smaller than 800/0.9=889px).

Droplet.maxWidth = Droplet.maxHeight = 800;
Droplet.threshold = 0.9; // default is 1.0

Droplet can also encode JPEG at different qualities to further reduce upload time (this is not supported in all browsers).

Droplet.quality = 0.5; // between 0.0 and 1.0, default is 0.8

droplet's People

Contributors

darktrojan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.