Code Monkey home page Code Monkey logo

react-virtualizer's Introduction

npm version npm license

@sullivan/react-virtualizer

Simple pseudo virtualization and reveal components to hide off-window components

Installation

npm install --save @sullivan/react-virtualizer

or

yarn add @sullivan/react-virtualizer

Usage

Virtual

The Virtual component hides its children when it is no longer visible within the browser window.

Props

prop type default
tag string div
style object {}
children React.Children []
rootMargin string | number 100px
initialHeight string | number 100vh
initialWidth string | number 100vw
import Virtual from '@sullivan/react-virtualizer';

const Item = () => (
  <Virtual tag={'p'}>
    Resource intensive component here
  </Virtual>
);

Reveal

The Reveal component doesn't show any of its children until it is scrolled into the browser window.

Props

prop type default
tag string div
style object {}
children React.Children []
import { Reveal } from '@sullivan/react-virtualizer';

const Image = ({ src }) => (
  <Reveal>
    <img src={src}>
  </Reveal>
);

Performance Tweaks

If you find that the Virtual component is slow to load while scrolling or tends to pop-in. You can tweak the initialHeight and initialWidth to be a closer approximation to the actual content. This helps speed up sibling Virtual components in determining their own dimensions.

Compatability

React 16.8.3+

Changelog

1.0.5

  • Performance improvements, obtaining dimensions from entry instead of forcing a repaint on the component
  • Adding number support for initialHeight, initialWidth, and rootMargin

1.0.4

  • Added initialHeight and initialWidth to allow for more fine controls of item rendering

1.0.3

  • Improved loading times

1.0.0

  • First version published

react-virtualizer's People

Contributors

icarus-sullivan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.