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

rowgrid

v2.0.1

Published

A small, lightweight JavaScript plugin for placing items in straight rows

Downloads

1,274

Readme

rowGrid.js (no jQuery required)

rowGrid.js is a small, lightweight (~1kB gzipped) JavaScript plugin for placing images (or other items) in straight rows.

The grid is similar to grids on Google Image Search, Flickr, Shutterstock and Google+ images.

Features:

  • responsive
  • infinite scrolling
  • support for all modern browsers and IE >= 9

RowGrid.js is also available as jQuery plugin: https://github.com/brunjo/rowGrid.js

Example Grid

Do you like this project? Follow me on Twitter @3runjo.

How does it work?

All items must have the same height but the width can be variable. RowGrid.js justifies the items in straight rows so that the width of the rows equals the width of the container/parent element. At first rowGrid.js adjusts the margin between the items. If this is not enough rowGrid.js scales down the items.

Demos & Examples

Real world example: https://www.pexels.com/

Installation

Just include row-grid.js:

<script src="path/to/row-grid.min.js"></script>

You can install it also with Bower or npm:

  • Install with Bower: bower install rowGrid.
  • Install with npm: npm install rowgrid.

Usage

It is important that you either declare the width and height as attributes on the img tag or that you wait until the images are loaded before you start rowGrid.js.

HTML:

<div class="container">
  <div class="item">
    <img src="path/to/image" width="320" height="200" />
  </div>
  <div class="item">
    <img src="path/to/image" width="290" height="200" />
  </div>
  ...
</div>

JS:

var container = document.getElementsByClassName('container')[0];
rowGrid(container, {itemSelector: ".item", minMargin: 10, maxMargin: 25, firstItemClass: "first-item", lastRowClass: 'last-row'});

Relayout

You can relayout the complete grid with rowGrid(container);. If you appended items to the grid you can call rowGrid(container, 'appended'); to arrange just the new items in the grid. This is useful if you want to implement endless scrolling.

Parameters

The method rowGrid() expects two parameters. The first one has to be a DOM element and the second one a JavaScript object with options:

itemSelector (required)

  • value: string (CSS Selector)

The selector have to reference to all grid items.

minMargin (required)

  • value: number or null

This is the minimal horizontal margin between the items. The margin is only between the items not between the first/last item and the container.

maxMargin (required)

  • value: number or null

This is the maximal horizontal margin between the items.

minWidth

  • value: number
  • default value: 0

RowGrid.js only applies its grid system if the width of the window is greater than or equals to the specified value.

The default value is 0. This means the items always get arranged by rowGrid.js.

Also check out the demo in the example directory to see this option in action.

lastRowClass

  • value: string
  • default value: last-row

The first item in the last row gets this class.

firstItemClass

  • value: string
  • default value: undefined

The first item in every row gets this class.