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

@fablevision/interaction

v2.0.12

Published

Accessible interactivity designed for Canvas-based (Pixi, Phaser, EaselJS, etc) games.

Downloads

45

Readme

Fablevision Interaction

Accessible interactivity designed for Canvas-based (Pixi, Phaser, EaselJS, etc) games.

Context stacks

Both Keyboard and InteractionManager use stacks of interaction contexts, so that interactivity can be quickly superseded and then restored for things like popups or items that are grouped in the UI for keyboard controls. You'll be expected to use activateContext() with a context name in order to enable interactivity, and then popContext() to remove it when you are done. Listeners all use the Disposable pattern, so return an object that has a dispose() method for cleanup.

Keyboard usage

The Keyboard class is built upon KeyboardJS, so uses key names/combinations as documented there.

// initialize singleton
const keyboard = new Keyboard();

// elsewhere in code
const removeListener = Keyboard.instance.add('ctrl + s', () => save());

Importing

The main classes can be imported with import { InteractionManager, Keyboard } from '@fablevision/interaction';, but each plugin handler should be imported like so: import { PhaserHandler } from '@fablevision/interaction/dist/phaser';

Current plugin support: Pixi, Phaser 3

Interaction usage

// keyboard must be created first
const keyboard = new Keyboard();
// initialize singleton
// note that this should be done AFTER the constructor for something like Phaser, as when setting up the Handler this.game isn't generated until after construction
const interaction = new InteractionManager({
    // This can be the id of a div, or the HTMLDivElement directly, and will be filled with interactive divs.
    // *You* are responsible for ensuring that the div is the same size/scale/location as your canvas.
    // Note that you may need to keep it from scrolling, if elements are sometimes partially offscreen (but still focusable). You may also wish to use `user-select: none;` on it to prevent the text/image selection tinting.
    accessiblityDiv: 'interaction',
    // a handler specific to your canvas rendering style
    renderer: new PixiHandler(myPixiRenderer),
});
// manually enable interaction manager (there will be no input handling otherwise)
interaction.enabled = true;

// elsewhere in code
// use the interactive class specific to your canvas rendering style
const buttonInteractive = new PixiInteractive({
    pixi: myPixiButton,
});
buttonInteractive.onActivate.on(() => doTheThing());
InteractionManager.instance.activateContext({items: [buttonInteractive], name: 'MyContext'});