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 🙏

© 2025 – Pkg Stats / Ryan Hefner

svelte-zooming-ui

v0.0.46

Published

> **⚠️ Work In Progress**: While this library is functional and usable in its current state, it's still under active development. Breaking changes may occur in future versions.

Downloads

19

Readme

Svelte Zooming UI

⚠️ Work In Progress: While this library is functional and usable in its current state, it's still under active development. Breaking changes may occur in future versions.

A powerful and flexible zooming user interface library for Svelte applications. Create infinite canvas experiences with intuitive pan and zoom controls.

Features

  • Smooth pan and zoom interactions
  • Touch gesture support
  • Infinite canvas
  • Precise decimal-based positioning
  • Level of detail management
  • Responsive and performant

Installation

npm install svelte-zooming-ui

Core Components

ZoomingUIComponent

The main container component that provides the zooming canvas functionality:

<script>
    import { ZoomingUIComponent } from 'svelte-zooming-ui';
    
    let lookAt;
</script>

<ZoomingUIComponent bind:lookAt debug={false}>
    <!-- Your zoomable content here -->
</ZoomingUIComponent>

Positionable

A component for positioning elements within the zooming canvas:

<script>
    import { ZoomingUIComponent, Positionable } from 'svelte-zooming-ui';
    import Decimal from 'decimal.js';
</script>

<ZoomingUIComponent>
    <Positionable 
        x={Decimal(0)} 
        y={Decimal(0)} 
        width={Decimal(100)} 
        height={Decimal(100)} 
        depth={Decimal(1)}
    >
        <div>Your content here</div>
    </Positionable>
</ZoomingUIComponent>

Advanced Usage

Exports

The following is exported:

  • lookAt: Function to programmatically move the camera (x, y, scale, duration?, easing?)

Context Values

The following are available through Svelte context:

  • screen: A writable store containing viewport dimensions and position {x, y, w, h}
  • camera: A writable store containing view transformation state {x, y, z, scale, w, h, fov}
  • focusOn: Function to focus on a specific area (x, y, w, h, duration?, easing?, ratio?)

Camera Control

You can control the camera programmatically using the exported lookAt function, or access camera state through context:

<script>
    import { ZoomingUIComponent, lookAt } from 'svelte-zooming-ui';
    import { getContext } from 'svelte';
    import Decimal from 'decimal.js';
    
    const camera = getContext('camera');
    
    // Subscribe to camera changes
    $: console.log('Current scale:', $camera.scale.toString());
    
    function zoomIn() {
        // Double the current zoom level
        lookAt(
            $camera.x,
            $camera.y, 
            $camera.scale.times(2)
        );
    }
</script>

<ZoomingUIComponent>
    <button on:click={zoomIn}>Zoom In</button>
    <div>Current zoom: {$camera.scale.toFixed(2)}x</div>
</ZoomingUIComponent>

The camera context provides real-time access to:

<script>
    let lookAt;
    
    function centerOn(x, y, scale) {
        lookAt(x, y, scale);
    }
</script>

<ZoomingUIComponent bind:lookAt>
    <button on:click={() => centerOn(Decimal(0), Decimal(0), Decimal(1))}>
        Reset View
    </button>
</ZoomingUIComponent>

Level of Detail

Manage content detail based on zoom level:

<Positionable x={x} y={y} width={width} height={height}>
    {#if $frame.ratio <= 20.0}
        <HighDetailContent />
    {:else}
        <LowDetailContent />
    {/if}
</Positionable>

API Reference

ZoomingUIComponent Props

  • debug (boolean): Enables debug visualization
  • lookAt (function): Bind to control camera position

Positionable Props

  • x (Decimal): X coordinate
  • y (Decimal): Y coordinate
  • width (Decimal): Width
  • height (Decimal): Height
  • depth (Decimal): Z-index depth
  • debug (boolean): Enables debug visualization

Examples

Check out our example components:

  • Clickable.svelte: Interactive area example
  • LOD.svelte: Level of detail implementation
  • Embedded.svelte: Nested content example

Contributing

Contributions are welcome! Please see our contributing guidelines for details.

License

MIT License - see LICENSE.md for details