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

react-box-virtualization

v1.1.0

Published

Small component to help quickly virtualize boxes with different sizes and positions. Component support two types of rendering connects virtualized render and lazy render.

Downloads

11

Readme

react-box-virtualization

React component for the optimized rendering of large datasets by custom positioning and virtualization.

React box virtualizer works by only rendering part of a large datasets.

  1. It reduces the memory footprint by avoiding the over-allocation of DOM nodes.
  2. It reduces the CPU load by avoiding, calculating positions, and rendering all boxes immediately.

Below you can find a small diagram which is reflected the impact of react box virtualization. Only boxes whose coordinates in the viewport are will be rendered.

NPM registry License

react-box-virtualization-1

Install

# Yarn
yarn add react-box-virtualization

# NPM
npm install --save react-box-virtualization

Usage

  1. Import box virtualizer component
import { BoxVirtualizer } from 'react-box-virtualization';
  1. Create a variable which is responsible for mapping properties from your object to box props
const coordinatesMap = {
    x: 'xVal',
    y: 'yVal',
    width: 'widthVal',
    height: 'heightVal'
};

Here is the interface of typescript for this prop

interface ICoordinatesMap {
    x: string;
    y: string;
    width: string;
    height: string;
    opacity?: string;
    isVisible?: boolean;
    zIndex?: number;
}
  1. Add BoxVirtualizer component to your JSX code
<BoxVirtualizer
    coordinatesMap={coordinatesMap}
    data={dataset}
    isVirtualized={true}
    boxGap={20}
    visualizableContent={VisualizableContent}
/>

Supported props of BoxVirtualizer component

| Prop name | Description | Type | Default value | Required | | ------------------- | ------------------------------------------------------------------------------------------------------------------------------ | --------------- | ------------- | -------- | | data | Array of objects | any[] | - | yes | | coordinatesMap | Map object for mapping data item property to CSS visual property | ICoordinatesMap | - | yes | | visualizableContent | React component which will receive data item object as props | React.FC | - | yes | | isVirtualized | In case of false value, rendering of boxes will work with a lazy render concept which means each box will be rendered one time | boolean | true | no | | viewportHeight | Height of viewport can be all CSS acceptable units for the height property | string | '100%' | no | | viewportWidth | Width of viewport can be all CSS acceptable units for the width property | string | '100%' | no | | boxGap | Gap between boxes can be all CSS acceptable units for the padding property | number | 0 | no |

Demos

Here's a boxes with random positions and sizes Code Sandbox demo rendered by lazy render concept. (Dataset size 1.000.000 boxes) Here's a boxes with grid layout Code Sandbox demo rendered by virtualization concept. (Dataset size 100.000 boxes)

License

MIT Licensed © 2022 Hamik25