npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

trickling

v1.14.0

Published

A modern progress bar for web. Featuring realistic trickle animations to convince your users that something is happening!

Downloads

8,229

Readme

Trickling

A modern progress bar for web APP. Featuring realistic trickle animations to convince your users that something is happening!

Features

  • Support programmatically modify the style of the progress bar.
  • Support RTL languages.
  • Support Typescript.

Installation

# pnpm
$ pnpm add trickling

# yarn
$ yarn add trickling

# npm
$ npm i trickling

Usage

  1. Imports style.
import 'trickling/lib/style.css'
  1. Create a trickling progress instance in a single file.
// @/plugins/trickling-progress.ts

import { createTrickling } from 'trickling'

// Create a Trickling progress instance
const tricklingProgress = createTrickling({
  // Options
  // ...
})

// You can also change options after creating a Trickling progress instance
tricklingProgress.setOptions({
  // ...
})

// Export the instance
export { tricklingProgress }
  1. Using it where needed.
import { tricklingProgress } from '@/plugins/trickling-progress.ts'

// ...
// shows the Trickling progress bar
tricklingProgress.start()

// ...
// Then, completes the Trickling progress
tricklingProgress.done()

Options

| Key | Type | Default value | Description | | :---: | :---: | :---: | :---: | | minimum | number | 0.08 | Changes the minimum percentage used upon starting. | | maximum | number | 0.994 | Changes the maximum percentage used upon ending. | | easing | string | ease | Adjust animation settings using easing (a CSS easing string). | | speed | number | 200 | Adjust animation settings using speed (in ms). | | trickle | boolean | true | Turn off the automatic incrementing behavior by setting this to false. | | trickleSpeed | number | 1000 | Adjust how often to trickle/increment (in ms). | | showSpinner | boolean | true | Turn off loading spinner by setting it to false. | | appendTo | string, HTMLElement | body | Specify this to change the parent container. | | customWrapperClassName | string | '' | Specify this to add a class name into the parent container. | | color | string | #2299dd | Specify this to change color of the progress bar and spinner. | | progressBarHeight | string | 2px | Specify this to change height of the progress bar. | | spinnerOpacity | number | 1 | Specify this to change opacity of the loading spinner. | | spinnerSize | string | 18px | Specify this to change size of the loading spinner. | | spinnerStrokeWidth | string | 2px | Specify this to change stroke width of the loading spinner. | | rtl (Added in v1.6.0) | boolean | false | Change the progress direction to right-to-left. | | removeFromDOMWhenDone (Added in v1.9.0) | boolean | true | Remove the component from the DOM when done, re-add when needed. This can have performance implications on complex apps as style calculations are slow. If set to false, just hidden the DOM via display: none when progress done. | | zIndex (Added in v1.8.0) | number/string | 1031 | Specify this to change progress bar z-index. | | trickleIncrementalCurve (Added in v1.10.0) | function/Array | See below | You can use this option to configure the incremental curve of the trickle. |

Trickle Incremental Curve

Using this configuration allows you to easily change the default trickle increasing curve. Thus, each Progress bar has different incremental expressions.

  1. Default value
[
  { from: 0, to: 0.2, value: 0.1 },
  { from: 0.2, to: 0.5, value: 0.04 },
  { from: 0.5, to: 0.8, value: 0.02 },
  { from: 0.8, to: 0.99, value: 0.005 },
]
  • from: This represents the starting range of the current progress status (including).
  • to: This represents the end range of the current progress status (excluding).
  • value: This represents the progress increment value of the current range.
  1. Type definition see here.
  • Function: If you use it as a function, should returns a number or array.
  • Array: Just set it via a array.

Advanced usage

  1. Percentages: To set a progress percentage, call .set(n), where n is a number between 0..1.
trickling.set(0.0);     // Just same as .start()
trickling.set(0.4);
trickling.set(1.0);     // Just same as .done()
  1. Incrementing: To increment the progress bar, just use .inc(). This increments it with a random amount. This will never get to 100%: use it for every image load (or similar).
trickling.inc();
  1. If you want to increment by a specific value, you can pass that as a parameter:
trickling.inc(0.2);    // This will get the current status value and adds 0.2 until status is 0.994
  1. Force-done: By passing true to done(), it will show the progress bar even if it's not being shown. (The default behavior is that .done() will not do anything if .start() isn't called).
trickling.done(true);
  1. Get the status value: To get the status value, use .status.
trickling.status