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

@wonderlandlabs-pixi-ux/observe-drag

v1.2.8

Published

A stream-based subject for PixiJS in wonderlandlabs-pixi-ux

Readme

@wonderlandlabs-pixi-ux/observe-drag

observe-drag enforces a single active drag owner via a module-level pointer lock by default.

Behavior

  1. A pointerdown is accepted only when no active pointer is in progress.
  2. Accepted drags forward matching pointermove events (pointerId must match the accepted down).
  3. pointerup, pointerupoutside, or pointercancel ends the active drag and releases ownership.
  4. Competing pointerdown events while busy call onBlocked.
  5. A configurable inactivity watchdog auto-releases ownership if no matching pointermove is seen (abortTime, default 1000ms; set abortTime: 0 to disable).
  6. You can inject your own lock (activePointer$) at factory creation to override the default module singleton lock.
  7. If an app with render() is provided, drag moves trigger a throttled render (default 30ms, configurable via renderThrottleMs) and drag terminal events (pointerup, pointerupoutside, pointercancel) force a final render.

Usage

dragDecorator wraps your listeners and handles Pixi container movement with default assumptions:

  1. target is a Pixi Container-like object (position, optional parent.toLocal)
  2. pointer coordinates come from Pixi events (event.global)
  3. movement is calculated in parent-local space when possible (parent.toLocal(globalPoint))

1. Simple Dragging

import dragObserverFactory, {dragDecorator} from '@wonderlandlabs-pixi-ux/observe-drag';

const observeDown = dragObserverFactory({stage: app.stage, app});
const sub = observeDown(target, dragDecorator(), {dragTarget: myContainer});

2. Custom Listeners

const sub = observeDown(
  target,
  dragDecorator({
    onStart(event, dragTarget) {
      // optional domain setup
    },
    onMove(event, context, dragTarget) {
      // extra side effects after default movement
    },
    onUp(event, context, dragTarget) {
      // drag finished
    },
    onBlocked(event, dragTarget) {
      // another drag currently owns the stage
    },
    onError(error, phase, event, dragTarget) {
      // listener threw; handle safely
    },
  }),
  {
    dragTarget: myContainer,
    abortTime: 1500,
    getDragTarget(downEvent) {
      // optional dynamic target resolution
      return downEvent.pointerId === 2 ? altContainer : myContainer;
    },
    debug(source, message, data) {
      if (message === 'pointer.busy') {
        console.warn(source, message, data);
        return;
      }
      console.log(source, message, data);
    },
  },
);

3. Snapping / Transform

const sub = observeDown(
  target,
  dragDecorator({
    transformPoint(point) {
      return {
        x: Math.round(point.x / 10) * 10,
        y: Math.round(point.y / 10) * 10,
      };
    },
  }),
  {dragTarget: myContainer},
);

Notes

  • You do not need to re-subscribe after each pointerup; one subscription handles repeated drag cycles.
  • Returning context from onStart is optional.
  • Receiving context in onMove and onUp is optional; if onStart returns nothing, context is undefined.
  • If returned, onStart context can be any object and is passed into onMove and onUp.
  • Core observe-drag does not move targets by itself; use dragDecorator() for default target motion, or move the target in your own listeners.
  • Subscription options support dragTarget (static), getDragTarget(downEvent, context) (dynamic), and abortTime (watchdog timeout in ms; 0 disables it).
  • Factory options support activePointer$ so you can provide your own lock instead of using the default module singleton.
  • Factory options also support stage (when app is not provided), optional app for drag render calls, and renderThrottleMs to tune render throttle (default 30).
  • Drag render throttling uses an app-scoped shared helper cache (WeakMap), so multiple drag/zoom consumers on the same app share one throttle stream.
  • The first shared helper retrieval/config for a given app wins; later retrievals use that same timing profile.
  • Shared helper internals live for the app lifetime and auto-clean on app.destroy(...).
  • dragDecorator() provides default Pixi container dragging using parent-local coordinates, then delegates to your wrapped listeners.
  • dragDecorator() works with no parameters.
  • dragTargetDecorator() is deprecated and remains as a compatibility wrapper.
  • debug is part of the options object ({ debug(source, message, data) {} }), not a separate third-arg overload.
  • onError is reserved for thrown listener errors and internal callback failures. Busy contention uses onBlocked, not onError.