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

@badskuns/10101-art-image-viewer

v1.0.3

Published

The "10101-art-image-viewer" library is a simple and lightweight tool for displaying images with zooming and panning functionality. The library is designed to be easy to use and customizable, with a minimal API and no external dependencies.

Downloads

3

Readme

10101 Art Image Viewer

The "10101-art-image-viewer" library is a simple and lightweight tool for displaying images with zooming and panning functionality. The library is designed to be easy to use and customizable, with a minimal API and no external dependencies.

Dev mode

Installation

yarn

Start

npm start

Beta publish

npm run beta

Publish

npm publish

Usage

Installation

yarn add @badskuns/10101-art-image-viewer

Usage

import React from 'react';
import ArtImageViewer from '@badskuns/10101-art-image-viewer';

const MyComponent = () => {
  const src = 'https://example.com/image.jpg';
  const containerSize = { width: 800, height: 600 };
  const sourceSize = { width: 1600, height: 1200 };
  const baseFragment = null // any fragment that could be used as data anchestor of fragment
  const data: TokenFragment = [
    { tokenId: 'abc', left: 200, top: 200, width: 100, height: 100, filterColor: '#fff', filterOpacity: 0.3, baseFragment: baseFragment }
  ];

  return (
    <ArtImageViewer
      src={'./image.jpg'}
      containerSize={{width: '100vw', height: '100vh'}}
      sourceSize={{width: 1920, height: 1080}}
      data={data}
      hoverData={null}
      onHover={(fragment) => console.log(fragment)}
      onClick={(fragment) => console.log(fragment)}
      renderLoader={() => <div>Loading...</div>}
      focusData={null}
      freezeData={null}
    />
  );
};

Props

  • src: string (required) - the source url of the image to display.
  • containerSize: SizeType (required) - the size of the container element as an object of { width, height }.
  • sourceSize: SizeType (required) - the size of the original image as an object of { width, height } to recompute initial coordinates. Exist because downloaded image has different size from source image coordinates received.
  • data: TokenFragment<>[] (optional) - an array of objects representing labels to display on the image on hover or focus. Each object should have the properties label (string) and position (array of [x, y] coordinates).
  • hoverData: ImageViewerMouseEvent (optional) - an object representing the label to display on hover. Should have the properties label (string) and position (array of [x, y] coordinates).
  • onHover: function (optional) - a callback function to be called when the mouse is hovering over a label. Receives the data object for the label as an argument.
  • onClick: function (optional) - a callback function to be called when a label is clicked. Receives the data object for the label as an argument.
  • renderLoader: function (optional) - a function that returns a React element to be displayed while the image is loading.
  • focusData: ImageViewerMouseEvent (optional) - an object representing the label to display on focus. Should have the properties label (string) and position (array of [x, y] coordinates).
  • freezeData: ImageViewerMouseEvent (optional) - an object representing the label to display when the image is frozen. Should have the properties label (string) and position (array of [x, y] coordinates).

Basic description

This project was crated to resolve html dom limitations in rendering of thousands of elements. We are using canvas and canvas wrapper library pixi to render block elements. Because of pixi limitations of drawings amount that lead to performance degradation, we split drawing elements in different components and canvas layers

FragmentsToken - main layer responsible for filling blocks with parts of the image FragmentsBackground - responsible to fill viewport on focus FragmentsFill - responsible for filling blocks in different colors based on config FragmentsGrid - responsible for grid drawing around each block HoveredFragment - responsible for drawing animation of fragment hover NavigationControls - responsible for drawing scale and zoom progress bars

EventsWrapper - layer responsible for detecting mouse events and computations of intersections of fragments with mouse coordinates, dynamic logic includes scalable offsets on zoom

useZoomAnimationDraw - one of the most important parts of the logic. It's responsible for positioning and calculations for all fragments of viewport and provide logic of scaling and offsetting blocks during zoom

License

This project is licensed under the MIT License - see the LICENSE file for details.