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 🙏

© 2026 – Pkg Stats / Ryan Hefner

minsky-dom-state-manager

v1.0.0

Published

Manages states of dom elements

Readme

DomState Manager

Manages states of dom elements, …

State isn’t always easy to track, especially when state changes have to run through different steps in specific order while also performing specific tasks like css class management. States can be defined in advance, called when necessary and listened to when activated. It will apply the defined classes and attributes to a dom element during the step change.

Class type: Manager

Dependencies

  • EventDispatcher - 1.0.0
  • Ticker - 1.0.0

Getting started

DomStateManager can both be instantiated and extended as one wishes.

// Init manager to manage states of .overlay
const mgr = new DomStateManager({
    el: document.querySelector('.overlay'),
});

// add states
mgr.add('visible', [
	{ addClass: 'overlay--prepareForShow' },
	{ addClass: 'overlay--show', removeClass: 'overlay--prepareForShow' }
]);

mgr.add('hidden', [
	{ addClass: 'overlay--prepareForHide', duration: 100 },
	{ addClass: 'overlay--hidden', removeClass: 'overlay--prepareForHide' }
]);

Constructor Parameters

Args

Type: Object Default: {}

Configuration of the instance that will be created


Interface

Options

el

Type: DOM Element Default: null

The element that needs to be managed

states

Type: Object Default: null

A collection of state definition objects that will define what needs to happen when set. Property names of this object will be used as states, values will be used as step definitions of these states (must be array).

Properties

state

Type: Object Default: null

Active state definition. Changes when different state is set using set() method. Changing this value directly with a state definition will automatically trigger the manager to go through all the steps.

states

Type: Object Default: {}

Object collection of all the defined states that were added through the constructor or by using the add() method

currentStep (read-only)

Type: integer Default: 0

Current step the instance is at during a state change.

allClasses

Type: Array Default: []

List of all the classes that can be found in the states.

running (read-only)

Type: Boolean Default: null

Flag that defines if the manager is running through steps of a state.

version (static)

Type: String Default: ''

Version of the class definition

Methods

add

Parameters: state [, steps] Return: self

Adds a state to the state collection. States have an array of steps through which the manager will run when the state is activated.

set

Parameters: state [, args] Return: self

Sets the given state and triggers the manager to run through all the steps. Immediate and instant can be passed in args to set the first step immediately or jump to the last step instantly.

get

Parameters: state Return: state

Returns the requested state definition.

nextStep

Parameters: none Return: self

Applies the next step in the list of steps in the current state without applying anything. Won’t do anything if next step index exceeds the bounds of the step list.

tick

Parameters: [none] Return: self

Applies the next step in the list of steps in the current state and applies everything and will dispatch events. Won’t do anything if next step index exceeds the bounds of the step list.

destroy

Parameters: [none] Return: self

Clears all the states and destroys the object, leaving the element like it was when constructed.

Events

stateChange

Parameters: Event

Dispatched when a new state was activated. Event data contains step index, current step and current state.

stepChange

Parameters: Event

Dispatches when a new step was activated Event data contains step index, current step and current state.

[state name]

Parameters: Event

Dispatched when a new state was activated. Event data contains step index, current step and current state.

[step name]

Parameters: Event

Dispatches when a new step was activated Event data contains step index, current step and current state.


To Do

  • Make nextStep private as it dubious with the tick method.
  • Manage keyframe animations instead of class steps?
  • Handle tweens for js defined state changes?
  • Fix issue with first step not being held in momory while it is running (next step is now, which is wrong)