Giter VIP home page Giter VIP logo

mprogress.js's Introduction

MProgress.js

Google Material Design Progress Linear bar.

It uses CSS3 and vanilla JavaScript which doesn't depend on any other libraries.

Types and preview

Type 1. Determinate

Type 2. Buffer

Type 3. Indeterminate

Type 4. Query Indeterminate and Determinate

Or you can see all types together:

Vedio:Material Progress & activity

DEMO

See the Online demo

How to start

Install it

Include mprogress.min.js and mprogress.min.css in your target html file.

<link rel='stylesheet' href='mprogress.min.css'/>

<script src='mprogress.min.js'></script>

You can also install it via Bower or npm:

bower install --save mprogress
npm install --save mprogress

Basic usage

Example for the Determinate type

1.Instantiation:

var mprogress = new Mprogress();

2.Show and start the bar by using:

mprogress.start();

Or you can just use the following code to replace step 1 and 2:

var mprogress = new Mprogress('start');  //start it immediately

3.Finish the loading and hide it :

mprogress.end();

Advanced usage

All types have start and end methods.

Type1: Determinate

Determinate also has set and inc methods.

set(n)

Sets the progress bar status, where n is a number from 0.0 to 1.0.

eg:

mprogress.set(0.3);
inc()

Increases by a random amount.

eg:

mprogress.inc(); // Increase the bar with a random amount.
mprogress.inc(0.3); // This will get the current status value and adds 0.3 until status is 0.994

Type2: Buffer

Its always used for video loading, and you can use for other case.

Init Type Buffer :

var bufferIntObj = {
  template: 2
};
var bufferProgress = new Mprogress(bufferIntObj);
Start it:
bufferProgress.start();

If you want to start it immediately after instantiating it,you can use:

var bufferIntObj = {
  template: 2, // type number
  start: true  // start it now
};
var bufferProgress = new Mprogress(bufferIntObj);
End it:
bufferProgress.end();

Buffer also has set , inc and setBuffer methods

Type Buffer has two progress: main progress and buffer progress.

set(n)

Sets the main progress bar status (0,1)

setBuffer(num)

Sets the buffer progress bar status (0,1)

inc()

Increases by a random amount, including buffer bar.

Type3:Indeterminate

Init Type Indeterminate :

var intObj = {
  template: 3, 
  parent: '#customId' // this option will insert bar HTML into this parent Element 
};
var indeterminateProgress = new Mprogress(intObj);

Type Indeterminate just has start and end methods.

indeterminateProgress.start();

indeterminateProgress.end();

Type4:Query Indeterminate and Determinate

Init Type Query :

var intObj = {
  template: 4,
  parent: '#anothercustomId' // to other position
};
var queryProgress = new Mprogress(intObj);

Type Query just has start and end methods.

queryProgress.start();

queryProgress.end();

Configuration

Passing an object(configuration) to instantiated Mprogress

var mp = new Mprogress(configuration);

template

Set the progress bar type. (default: 1)

var mp = new Mprogress({
  // vaule { 
  //    1: Type Determinate,
  //    2: Buffer,
  //    3: Indeterminate, 
  //    4: Query,
  //  '<div>...</div>': 'yourcustomHTML'
  // }
  template: 2 
});

parent

Change the parent container where the bar is shown. (default: body)

var mp = new Mprogress({
  parent: '#customContainer' 
});

start

Start the bar immediately. (default: false)

var mp = new Mprogress({
  template: 4,
  start: true
});

For type1 Determinate, you can just use:

var mp = new Mprogress('start');

Advanced Configuration

trickle

trickleRate

trickleSpeed

minimum

easing

positionUsing

speed

Browser Support

Mobile First.

All types work in Chrome and Firefox.

Type Determinate works in all browsers.

License

MIT © gctang

mprogress.js's People

Contributors

fay-jai avatar freaktechnik avatar kkirsche avatar lightningtgc avatar orengriffin avatar

Stargazers

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

Watchers

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

mprogress.js's Issues

Example for type 4 to type 1 transition

In your example videos you have a type 4 Query that transitions to Type 1 Determinate. Do you have any working examples?

With the type 4 .end() method it appears as if your loading/progress is finished by zooming all the way right, but that's not what the video of the transition does. And trying to manage 2 MProgress bars on the same element as if to replace the 1st Type 4 bar doesn't work with the lib. Once you .end() the first one on an element, a new bar appears on the element.

package.json contains bad characters

$ cat -A node_modules/mprogress/package.json
M-oM-;M-?{$
  "name": "mprogress",$
  "description": "Mprogress.js creates progress linear bar from Google Material Design.",$
  "version": "0.1.1",$
  "homepage": "https://github.com/lightningtgc/MProgress.js",$
  "author": "tang guichuan <[email protected]>",$
  "repository": {$
    "type": "git",$
    "url": "git://github.com/lightningtgc/MProgress.js.git"$
  },  $
  "devDependencies": {$
    "gulp": "^3.8.10",$
    "del": "^1.1.1",$
    "gulp-uglify": "^1.1.0",$
    "gulp-rename": "^1.2.0",$
    "gulp-es6-module-transpiler": "^0.2.1",$
    "gulp-stylus": "^2.0.0",$
    "gulp-minify-css": "^0.4.5"$
  }$
}$

M-oM-;M-? this is bad

Webpack fails with this package.json

CSS 3D transforms for hardware-accelerated animations?

Thank you for your work on this library.

I tried using this on a project recently and while it definitely looks great, the animations can get a bit choppy during the initial loading screen where a lot of JS is being loaded and executed.

I'm wondering if you've already looked into the possibility of using the 3D variants of the CSS transform functions you're using (i.e. translate3d() vs translateX(), and scale3d() vs scaleX())? I think there might be some room for performance increases here since the 3d versions are hardware-accelerated.

Thanks!

Register on Bower

We should gain even more traction once the project is registered with Bower. It will allow seamless integration for those who live by the Bower :-D

two instants of loader

I use it on angular js and create class to manage it

 var clsLoader = (function () {
        var mprogress = new Mprogress({
            template: 2
        });
        return {
            show: function () {
                mprogress.start();
            },
            hide: function () {
                mprogress.end();
            }
        }
    })();

when i have two call for function show, and two call for function hide the loader not ended?

Two instance at the same time?

When I try to use two instance of MProgress.js, both of them did not show up. There something did I wrong? Or it doesn't support two instance in same page at this time?

Add main entrypoint to package.json

At the moment, if you execute require("mprogress") in node, the error Error: Cannot find module 'mprogress' is produced. Adding a main entry in package.json will fix this

Project still active?

@lightningtgc is this project still actively maintained? Looks like the changes over the past year or so haven't been released yet, so just curious. Thanks!

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.