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.js

v1.1.0

Published

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

Downloads

89

Readme

rowGrid.js

rowGrid.js is a small, lightweight (~1000 bytes gzipped) jQuery 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 >= 8

A vanilla JavaScript version is available that doesn't require jQuery: https://github.com/brunjo/rowGrid

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

Examples with explanation: http://brunjo.github.io/rowGrid.js/

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

Installation

RowGrid.js requires jQuery 1.7 or above.

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

You can install it also with Bower or npm:

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

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 options = {minMargin: 10, maxMargin: 35, itemSelector: ".item"};
$(".container").rowGrid(options);

Endless Scrolling

JS:

// append new items
$(".container").append("<div class='item'><img src='http://placehold.it/310x200' /></div>");
// arrange appended items
$(".container").rowGrid("appended");

Options

$(".container").rowGrid({
    itemSelector: ".item"
    minMargin: 10,
    maxMargin: 35,
    resize: true,
    lastRowClass: "last-row",
    firstItemClass: "first-item"
});

itemSelector (required)

  • value: string (CSS Selector)

You have to set this option. The selector have to reference to all grid items.

minMargin

  • value: number or null
  • default value: 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

  • value: number or null
  • default value: null

This is the maximal horizontal margin between the items.

resize

  • value: boolean
  • default value: true

If resize is set to true the layout updates on resize events. This is useful for responsive websites.

lastRowClass

  • value: string
  • default value: last-row

The first item in the last row gets this class.

firstItemClass

  • value: string or null
  • default value: null

The first item in every row gets this class.

lastItemClass

  • value: string or null
  • default value: null

The last item in every row gets this class.