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

ldloader

v3.0.3

Published

loader manipulation library

Downloads

159

Readme

ldloader

handy library to manipulate loader's state. for more information, please check ldloader documentation.

Usage

create an object for each loader you want to use:

var ldld = new ldloader(config);

config includes following options:

  • root: element for your loader. default null
    • could be css selector, element, or array of css selectors/elements.
    • ldloader will create one automatically if omitted, and append it under container.
    • if root is an array, ldloader instance will work on every element in the array.
  • container: where root should be put in.
    • will be root.parentNode if omitted.
    • will be document.body if both root and container is omitted.
    • note: container is also an array since root by design accept array of value.
  • class-name: additional class over root. default '' and is optional.
    • you can also add classes directly onto the root element you provided.
  • active-class: class added to root when loader is toggled on. default 'running'.
    • useful when working with different css libraries.
  • inactive-class: class added to root when loader is toggled off. default is null.
  • auto-z: update root's z-index automatically. default false.
  • base-z: the minimal z-index of root. default 10000.
    • with auto-z, ldloader keeps track of all loaders' z-index and always use larger z-index for newly toggled loaders. base-z is then used as a base value for all auto-z loaders.
  • ctrl: custom animation control unit. should at least contains a member function "step(t)".
    • step(t): will be invoked repeatedly by requestAnimationFrame during loading period. context (aka this) will be root.
  • atomic: default true. when atomic is false, you will need N ldloader.off() call to dismiss ldloader if there was already N ldloader.on() call.
  • toggler(v): optional toggler triggered when on/off status changed. useful for chaining toggling events.
    • v: on/off status.

Methods:

  • on(delay): toggle loader on. return promise. (if delay is provided, wait delay(ms) before on )
  • off(delay): toggle loader off. (if delay is provided, wait delay(ms) before off )
  • cancel(v): cancel delayed action. force state to v if v is defined.
  • is-on: return true if loader is running, else false.
  • toggle(state,delay): toggle loader based on state(true/false). toggle according to current state if state is omitted. return promise ( delay behavior according to whether it's on or off )
  • on(event, cb): listen to events, including: ( TBD? conflict with on(delay) )
    • toggle.on
    • toggle.off

Class Method

  • setZmgr(zmgr): set a shared z-index manager. useful to manager widget z-index globally. this manager should provide following methods:
    • add(baseVal, size): return actual added value.
      • baseVal: hint value for the z-index we'd like to use
      • size: hint size about how large the object we added is
    • remove(val): remove val ( returned by add ) from this manager.

Styling and Structure

There is no constraint about how ldloader's DOM structure should be. Basically it contains an element for loader, and the element's parent in which the loader is shown. You control all the animation and effects based on active-class toggled by ldloader.

For convenience, ldloader is shipped with some builtin css for simple usage:

  • .ldld.bare - rotating double ring, placed at where it should be.
  • .ldld.default - rotating double ring centered in it's container. container should have style position: relatve/absolute/fixed.
  • .ldld.full - dimed full screen blocking loader, with rotating double ring in the middle.
  • size modifier for .ldld.bare and .ldld.default:
    • .sm - 16 x 16
    • .em-1 - 1em x 1em ( useful in button )
    • .em-2 - 2em x 2em
  • color modifier:
    • without color modifier, it will currentColor by default.
    • .ldld.light - rgba(255,255,255,.5)
    • .ldld.dark - rgba(0,0,0,.5)

You can also use ldloader along with loading-btn and loading.css:

<div class="btn ld-ext-right">
  Load
  <div class="ld ld-ball ld-bounce"></div>
</div>
<script>
  var ldld = new ldloader({root: ".ld-ext-right"});
  ldld.on(); ldld.off(1000);
</script>

License

MIT