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

umbr-resizer-two

v1.0.17

Published

A simple, dependency-free vanilla JS class for resizable split views.

Readme

umbr-resizer-two

A lightweight, zero-dependency TypeScript library that automatically manages a resizable handle between two children in a container. It uses a MutationObserver to stay active even if panels are dynamically added or removed.

Installation

npm install umbr-resizer-two

Example

Instead of importing from dist import it from npm package name

<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Resizer Demo</title>
    <style>
      * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
      }

      html,
      body {
        width: 100%;
        height: 100%;
      }

      body {
        display: flex;
      }

      .container {
        display: flex;
        flex: 1;
        position: relative;
      }

      .panel {
        flex: 1;
        overflow: auto;
        padding: 20px;
        background: #1e1e1e;
        color: white;
      }

      .hidden {
        display: none !important;
      }

      /* Visual indicator for the reopen handle */
      .reopen-indicator {
        display: flex;
        align-items: center;
        justify-content: center;
        color: #666;
        font-size: 12px;
      }
    </style>
  </head>
  <body>
    <div id="container" class="container">
      <div class="panel" id="panel_one">Panel 1</div>
      <div class="panel" id="panel_two">Panel 2</div>
    </div>

    <script type="module">
      import { Resizer } from "./dist/resizer.js";
      import { ResizerReOpenHandle } from "./dist/reponHandle.js";

      let resizer = null;
      let reopenHandle = null;
      const container = document.getElementById("container");
      const panelOne = document.getElementById("panel_one");
      const panelTwo = document.getElementById("panel_two");

      // Store panelOne content for restoration
      const panelOneContent = panelOne.innerHTML;

      function createResizer() {
        // Ensure both panels are in DOM
        if (!document.getElementById("panel_one")) {
          // Restore panel_one if removed
          const newPanelOne = document.createElement("div");
          newPanelOne.id = "panel_one";
          newPanelOne.className = "panel";
          newPanelOne.innerHTML = panelOneContent;
          container.insertBefore(newPanelOne, panelTwo);
        }

        // Remove reopen handle if exists
        if (reopenHandle) {
          reopenHandle.dispose();
          reopenHandle = null;
        }

        resizer = new Resizer(
          {
            container: container,
            direction: "horizontal",
            handleStyles: {
              width: "8px",
              background: "#2a2a2a",
              cursor: "col-resize",
              transition: "background 0.2s ease",
              position: "relative",
              zIndex: "10",
              flexShrink: "0",
            },
            minFlex: 0.1, // Lower min to allow collapsing
            storageKey: "storage_key",
          },
          {
            onBeginDrag: () => {
              console.log("[Resizer] onBeginDrag");
            },
            onDrag: (values) => {
              // Optional: live feedback
            },
            onDragFinished: (values) => {
              console.log(`[Resizer] onDragFinished: ${values}`);
            },
            onDragPastMin: (side, pixels) => {
              console.log(`[Resizer] onDragPastMin: ${side}, ${pixels}px`);

              // If dragged 50px past left minimum, collapse panel
              if (side === "left" && pixels > 50) {
                collapsePanel();
              }
            },
          },
        );
      }

      function collapsePanel() {
        console.log("[App] Collapsing panel...");

        // Dispose resizer
        resizer.dispose();
        resizer = null;

        // Remove panel_one from DOM
        const p1 = document.getElementById("panel_one");
        if (p1) p1.remove();

        // Create reopen handle on the left side of remaining panel
        reopenHandle = new ResizerReOpenHandle(
          {
            container: container,
            handleStyles: {
              width: "20px",
              background: "#2a2a2a",
              cursor: "col-resize",
              transition: "background 0.2s ease",
              position: "relative",
              zIndex: "10",
              flexShrink: "0",
              display: "flex",
              alignItems: "center",
              justifyContent: "center",
            },
            position: "left", // Handle on left side of panel_two
          },
          {
            onBeginDrag() {
              console.log("[ReOpenHandle] onBeginDrag");
            },
            onDrag(pixels) {
              console.log(`[ReOpenHandle] onDrag: ${pixels}px`);

              // If dragged 50px to the right (positive), restore panel
              if (pixels > 50) {
                restorePanel();
              }
            },
            onDragFinished(pixels) {
              console.log(`[ReOpenHandle] onDragFinished: ${pixels}px`);
            },
          },
        );

        // Add visual indicator
        const handle = container.querySelector(
          "div[style*='cursor: col-resize']",
        );
        if (handle) {
          handle.innerHTML = "›";
          handle.style.color = "#666";
          handle.style.fontSize = "16px";
        }
      }

      function restorePanel() {
        console.log("[App] Restoring panel...");

        // Dispose reopen handle
        if (reopenHandle) {
          reopenHandle.dispose();
          reopenHandle = null;
        }

        // Recreate panel_one
        const newPanelOne = document.createElement("div");
        newPanelOne.id = "panel_one";
        newPanelOne.className = "panel";
        newPanelOne.innerHTML = panelOneContent;

        // Insert before panel_two
        container.insertBefore(newPanelOne, panelTwo);

        // Restore resizer
        createResizer();
      }

      // Initialize
      createResizer();
    </script>
  </body>
</html>