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

tilegrid

v0.1.1

Published

A almost infinitely scrolling tile component with support variable height and width tiles, Backbone.js React and ReactDatum

Downloads

43

Readme

tilegrid

An almost infinitely scrolling tile display component for variable height and variable width tiles. With built in support for React >= v0.14 and Backbone.js >= v0.9.2

Also compatible with react-datum

What does it do?

The Tilegrid component renders a tile containing it's children for each model in a [Backbone.js] collection.

  • supports single select

  • supports multi/drag select

  • lazily renders tiles

  • lazily derenders tiles outside the view port

  • supports variable height and width tiles within the same grid

  • supports nested Tilegrid components

simple example using React:

// KITTEN_DATA is a static array of data from petfinder api
//    that gets loaded via script tag for the examples
var kittenCollection = new Backbone.Collection(KITTEN_DATA)

var MyTilegridDisplay = React.createClass({
  render: function(){
    return (
      <ReactTilegrid collection={kittenCollection}>
        <MyKittenCard/>
      <ReactTilegrid>
    )
  }
})  

The example above will render one of your MyKittenCard component per Backbone model in the Backbone collection. The Tilegrid component will make the Backbone model for that tile available as context variable to all ancestors and as a direct react property to MyKittenCard.

simple example without React:


var kittenCollection = new Backbone.Collection(KITTEN_DATA)
var tileTemplate = "<div/>"

var tilegrid = new Tilegrid("#kittenTilegrid", kittenCollection, tileTemplate, {
  onTileRendered: function($tile, model){
    // at this point you can do anything with the tile 
    $tile.text("This kitty's name is " + model.get('name'))
  }
})

Tilegrid will take care of rendering and derendering your tiles as they come in and out of user view.

Tilegrid uses a bump-extend strategy for rendering tiles. Tiles are added to the end of the rendering area as the user scrolls down the page. As a result, you can not immediately scroll to the bottom of a large result set. The trade off is that you can easily render tiles that are variable height, variable width or both.

Tilegrid derenders tiles. When the user scrolls up or down in the view, tiles will be derendered that are a configurable distance from the viewport. To derender tiles, height and width fixed and all content in the tile element, html and text, is removed. When the tile is later scrolled back into view, the tile is rendered back into existance and onTileRendered is called again for that tile.

By default, tiles are rendered as display: inline-block and will render to the size of the content in them. You control styling and preferred styling of tiles via CSS. So, if you wanted tiles like ones on the left of the examples viewer (TODO: link to demo viewer), you could add a css rule that sets the width of the .tile element. You can also change the display style of the tile to display: block if you wanted to force one tile per row regardless of viewport width.