ToProgress.js

943 阅读1分钟

A lightweight, no-dependency top bar library

0. Import script

1. Set options (The values below are default value)

var options = {
 id: 'top-progress-bar',
 color: '#F44336', 
 height: '2px', 
 duration: '.2' 
}

2. Get the progress bar instance

var progressBar = new ToProgress(options);

3. Play it!

progressBar.increase(20);

new ToProgress(options[,selector])

  • options
    • id - the id of auto-created top bar element
    • color - top bar color
    • height - top bar height
    • duration - increase duration (seconds)
  • selector - valid css selector, if is defined, topbar will put on the top of the element

.increase(progress)

  • progress- percentage number

.decrease(progress)

  • progress- percentage number

.setProgress(progress)

  • progress- percentage number

.getProgress()

.finish()

.show()

.hide()