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

debut-css

v0.11.0

Published

Simple entrance and exit animations using CSS transitions.

Downloads

156

Readme

Debut CSS

Simple entrance and exit animations using CSS transitions.

Define simple transitions in your CSS, compose them in your HTML, and trigger them with JavaScript.

<dialog data-debut="fade">
.fade { /* */ }

.fade--before-enter { /* */ }
.fade--enter {/* */}
.fade--after-enter {/* */}

.fade--before-exit { /* */ }
.fade--exit {/* */}
.fade--after-exit {/* */}
import {enter, exit} from "debut-css"

const dialog = document.querySelector("dialog")
await enter(dialog)
await exit(dialog)

How It Works

These are the steps.

  1. Target the elements you wish to transition.
  2. Apply the above classes at the proper times to each element.
  3. Resolve the promise when all transitions above have settled.

Caveat: When calling enter or exit on an element with no transition-duration value, the promise will never return. It will wait for the first transition-start event indefinitely. I plan to add a failsafe for that case that throws an error after 1 second if no transition-start event comes around.

Targeting Elements

As for targeting, there are two ways.

  1. Pass in the exact elements you wish to transition.
  2. Pass in the name of a "target". A target is set using the data-debut-target attribute. Any elements in the DOM that have that target value will be transitioned.

You can plug-n-play these targeting strategies as arguments to enter and exit.

enter(...targetArguments)
exit(...targetArguuments)

For example, here we target a

<body data-debut="fade move" data-debut-target="modal-backdrop"></body>
<dialog> 
    <-- Assume this dialog has the onClick event listener attached to it-->
</dialog>

<script>
function onClick(e) {
    await exit(e.currentTarget, "modal-backdrop")
    e.currentTarget.close()
}
</script>

To avoid needing to use the same targeting strageties for both the enter and the exit functions, you can use the target method, then call enter and exit on it. The target object will re-query the DOM if it needs to at the start of the enter and exit methods.

const modal = target("modal-foreground", "modal-backdrop")
await modal.enter()
await modal.exit()
class MyHandlerClass {
    constructor() {
        this.modal = target("modal-fg", "modal-bg")
    }

    open() {
        this.modal.enter()
    }

    close() {
        this.modal.exit()
    }
}