Giter Site home page Giter Site logo

amin52j / download-progress Goto Github PK

View Code? Open in Web Editor NEW
14.0 2.0 4.0 8 KB

A small, low-level library/API to create awesome file downloading progress bars.

License: MIT License

JavaScript 54.11% HTML 45.89%
javascript loading loading-screen loading-page loading-bar progress progress-bar progressbar library

download-progress's Introduction

Download Progress

A small, low-level library to create awesome file download progress bars.

How to start?

  • Install using npm npm install download-progress
  • If using ECMAScript 6 then import DownloadProgress from 'download-progress' then DownloadProgress(filesToLoad)
  • If using ECMAScript 5 then include <script src="[PATH-TO-FILE]/download-progress.js"></script> in the head of your index.html then DownloadProgress(filesToLoad)

How to use?

//set up the library
var files = ['myJS.js','myCSS.css','myText.txt'];
var dp = DownloadProgress(files);

//add event listeners
dp.on('progress',function(e){
    console.log(e.detail + ' combined percentage loaded!');
}).on('afterLoading',function(e){
    console.log(e.detail.url + ' is completely loaded!');
    console.log(e.detail.response); //this is the content of the loaded file
});

//initialize
dp.init();

Methods

  • on: Attaches a callback to one of the events
  • init: Initializes the loading process

Events

  • beforeLoading: Dispatches right before the download process starts
  • afterLoading: Dispatches once after each url is completely loaded
  • progress: Dispatches when the progress value (the percentage) changes

NOTE

For seeing the progress of gzip files you need to set a header for the file in the backend api called x-decompressed-content-length so that Download Progress can get the uncompressed file size and calculate the progress.

Feel free to contribute, leave suggestion or issues.

License

This project is licensed under the MIT License.

download-progress's People

Contributors

amin52j avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.