• Stars
    star
    306
  • Rank 136,456 (Top 3 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created almost 6 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

❤️ A lightweight (1KB) progress bar with promise support


A simple(1KB) progress bar with promises support

npm npm npm

The progress bar is initially fast, but doesn't end as it slows down. Call the end function to complete.
This gives users a natural animation without the exact percentage of progress.

https://skt-t1-byungi.github.io/rsup-progress/

Example

Example using start, end method.

progress.start()

fetch('/data.json').then(response => {
    progress.end()
})

Using promise method.

const response = await progress.promise(fetch('/data.json'))

Install

npm i rsup-progress
import { Progress } from 'rsup-progress'

Browser ESM

<script type="module">
    import { Progress } from 'https://unpkg.com/rsup-progress/dist/esm/index.js';
    const progress = new Progress()
</script>

API

new Progress(options?)

Create instance.

const progress = new Progress({
    height: 5,
    color: '#33eafd',
})

options

  • height - Progress bar height. Default is 4px.
  • className - Progress bar class attribute.
  • color - Progress bar color. Default is #ff1a59.
  • container - Element to append a progress bar. Default is document.body.
  • maxWidth - Maximum width before completion. Default is 99.8%.
  • position - Position to be placed. Default is top (There are top, bottom, none).
  • duration - Time to reach maxWidth. Default is 60000(ms).
  • hideDuration - Time to hide when completion. Default is 400(ms).
  • zIndex - CSS z-index property. Default is 9999.
  • timing - CSS animation timing function. Default is cubic-bezier(0,1,0,1).

progress.setOptions(options)

Change options.

progress.setOptions({
    color: 'red',
    className: 'class1 class2'
})

progress.isInProgress

Returns whether it is in progress or not.

console.log(progress.isInProgress) // => false

progress.start()

console.log(progress.isInProgress) // => true

progress.start()

Start the progress bar.

progress.end(immediately = false)

Complete the progress bar. If immediately is true, remove the element immediately.

progress.promise(promise, options?)

Call the start and end functions automatically by promise.

const response = await progress.promise(fetch('/data.json'))

options.min

Minimum time to show and maintain the progressbar. Default is 100ms. If 0 is given and promise is already resolved, the progressbar does not appear.

progress.promise(Promise.resolve(), { min: 0 }) // => Progress bar does not appear.

options.delay

If options.delay is given, it starts after a delay.

progress.promise(delay(500), { delay: 200 }) // => It starts 200ms later.

If the promise ends before the delay, the progress bar will not start.

progress.promise(delay(500), { delay: 600 }) // => Progress bar does not appear.

It is useful when avoiding the progressbar flash that occurs when the promise is short.

License

MIT License ❤️📝 skt-t1-byungi

More Repositories

1

use-simple-store

🏬 Simple state management using React Hook
TypeScript
23
star
2

use-waiter

🤵 A react hook to wait for an asynchronous order.
TypeScript
13
star
3

korean-devtube

📺 개발 관련 한국어 유튜브 채널 모음.
11
star
4

noonnu-fonts

눈누 폰트들을 npm 패키지로 제공합니다
CSS
11
star
5

aico

🦄 abort in coroutines
TypeScript
11
star
6

wedding-card

동생 결혼식 모바일첩청장입니당~
JavaScript
8
star
7

use-ref-deps-effect

Effect hooks that support "ref.current" dependencies
TypeScript
7
star
8

rsup-mqtt

📢 Elegant wrapper for the paho mqtt client
JavaScript
7
star
9

inno-trans

📜 simple localization library (inspired by laravel translation)
TypeScript
6
star
10

react-router-refreshable

Supports refresh (remount) on react-router-dom
TypeScript
6
star
11

ytdl-run

youtube-dl runner in node.js
JavaScript
6
star
12

thejungle

🌴🐒 scss utility collection
SCSS
6
star
13

use-deferred

React hook to handle the deferred promise.
TypeScript
6
star
14

use-imperative-portal

Imperative React hooks for Portals
TypeScript
5
star
15

clearall

🧹 Clear all event listeners at once.
TypeScript
5
star
16

jQuery.xon

simple prevent multiple jQuery ajax(throttle)
JavaScript
5
star
17

svelte-wordle

Wordle implemented by svelte, tailwind
Svelte
4
star
18

gulp-edgejs

Edge.js(http://edge.adonisjs.com) template engine
JavaScript
4
star
19

use-interpolate

📃 A react hook that interpolates markup tags into components
TypeScript
4
star
20

eggdown

🥚 egghead downloader for pro members
JavaScript
4
star
21

parcel-plugin-server

Parcel plugin for dev server setting.
JavaScript
3
star
22

zendesk-themer

CLI for zendesk hc theme deploy
JavaScript
3
star
23

byunx

state management + event emitter + reactive stream
TypeScript
3
star
24

servernow

Get server timestamp in browser
TypeScript
3
star
25

CHOMini

PHP mini Framework
PHP
3
star
26

thebook-pdfy

더북(https://thebook.io/) 공개책 pdf로 저장하기
JavaScript
3
star
27

jquery-statebus

🚍 Small state management library for jQuery
JavaScript
3
star
28

promise

A promise collection.
TypeScript
3
star
29

php-slim-blog

php slim3으로 제작된 블로그 소스입니다.
PHP
3
star
30

get-puppeteer-browser

Get a singleton puppeteer browser instance.
JavaScript
3
star
31

my-read-books

읽은 책들 목록 정리
TypeScript
3
star
32

event-emitter

Small (< 600Byte), type-safe event emitter that support old browsers
TypeScript
3
star
33

gulp-velocityjs2

Gulp compile plugin for velocity(http://velocity.apache.org) template.
JavaScript
2
star
34

fastcampus-downloader

A fastcampus downloader for paying students.
JavaScript
2
star
35

fromis

A simple promise implementation (~300Byte)
JavaScript
2
star
36

tag-name-parser

A tag parser that does not support attributes. Lightweight and fast.
JavaScript
2
star
37

lotto-is-answer

다 부질없다. 로또가 답이다.
JavaScript
2
star
38

jQuery.formWhen.js

jQuery Interactive Form Helper
JavaScript
2
star
39

wox-npm-bundlephobia

😱 wox npm bundlephobia plugin
Go
2
star
40

npi

npm pack and install a remote package
JavaScript
2
star
41

femdown

👹 FrontendMasters downloader
JavaScript
2
star
42

nanum-square-fallback

Nanum square (나눔스퀘어) font with fallback
CSS
1
star
43

rsup-timespan

Timespan library for browser
JavaScript
1
star
44

use-eager-effect

TypeScript
1
star
45

jar-got

A wrapper for got to persisting cookies
JavaScript
1
star
46

loose-openapi-ts

1
star
47

rsup-duration

Convenient duration time utility
TypeScript
1
star
48

oauth2-naver

Naver OAuth 2.0 Client Provider
PHP
1
star
49

mygallery

1
star
50

jQuery.aa.js

[deprecated] simple view plugin by jquery, mustache
JavaScript
1
star
51

mvc-in-jquery

다른 프레임워크 도입없이 제이쿼리로 모델, 뷰를 분리하기
JavaScript
1
star
52

formoe

TypeScript
1
star
53

go-algos

algorithms and data structures implementation in Go
Go
1
star
54

rx-mimic

A generator based RxJS implementation for learning
JavaScript
1
star
55

nonstated

simple react state management library (inspired by unstated)
JavaScript
1
star
56

mergeri

A simple object merger using matcher.
JavaScript
1
star
57

Streaming-HTML-test

JavaScript
1
star
58

skt-t1-byungi

1
star
59

jsooon

1
star
60

eslint-config-byungi

byungi's eslint config
JavaScript
1
star
61

jquery-statebusking

🎸 Backbone alternative using jquery-statebus
JavaScript
1
star
62

100_korean

"숫자로 보는 한국인의 생각과 라이프스타일" 페이지를 고정퍼센트로 리다이렉트 합니다.
HTML
1
star
63

lru-cache

Typed, fast LRU cache for browser.
TypeScript
1
star
64

ps_clang

C
1
star
65

promise-to-signal

Convert a Promise to a AbortSignal.
JavaScript
1
star