GithubHelp home page GithubHelp logo

weaverse / animate-loading-bar Goto Github PK

View Code? Open in Web Editor NEW
26.0 1.0 0.0 782 KB

1kb loading bar like Shopify, Github, JSFiddle... that works!

Home Page: https://hta218.github.io/animate-loading-bar/

JavaScript 20.70% SCSS 10.42% HTML 68.88%
animation-css loading-bar tiny shopify-loading github-loading-bar jsfiddle-loading-bar github

animate-loading-bar's Introduction

Logo

Animate Loading Bar

1kb loading bar like Shopify, Github, JSFiddle... that works!
View Demo

Bundle phobia

Installation

  1. Via npm
    npm install animate-loading
    Or yarn
    yarn add animate-loading
  2. Import to your project
    import 'animate-loading/dist/main.css'
    import AnimateLoading from 'animate-loading'
  3. Usage
    // Create an instance in your project
    const loading = new AnimateLoading()
    
    // Start loading
    loading.start()
    
    // Execute your async stuff
    await fetch('YOUR_API')
    
    // Finish loading
    loading.finish()

Available options

const loading = new AnimateLoading(target, options)
  • target [HTMLElement]: where the loading bar shows up. (Default value: document.body)
  • options [Object]: Loading options
    • options.overlay [HTMLElement]: Set a blur overlay to your node (if neccessary)
    • options.thickness [String]: the loading bar thickness (Default value: 3px)
    • options.color [String]: the loading bar background color (Default value: gray)
    • options.startDuration [Number]: The duration (in ms) from the start of your async stuff until it gets done (Default value: 1000)
    • options.finishDuration [Number]: The duration (in ms) left to finish loading (Default value: 300)

Methods

  1. Start loading

    loading.start()

    Run this before starting your async stuff

  2. Finish loading

    loading.finish(callback = () => {})

    Run this after your async stuff gets done.

    Optional callback can be pass to run after finishing the loading process.

Credit

Copyright (c) 2022 Leo Huynh @ https://leohuynh.dev

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.