• Stars
    star
    189
  • Rank 204,649 (Top 5 %)
  • Language
    JavaScript
  • Created over 10 years ago
  • Updated about 10 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A small JavaScript class to programmatically position content with variable widths and heights and minimizing whitespace gaps. Imagine Pinterest on steroids (Pinterest only allows for variable height). By Jason Mayes

Smart-Content-Placer

A small JavaScript class to programmatically position difficult content. What do I mean by that? Well lets assume you have many images which are different widths and heights. How do you place them on a page such that there are no "gaps"? This is basically a constrained bin packing problem. Using just CSS this is a no go as you will end up with blocks of whitespace appearing, thus some JavaScript is required. This little component allows for variable width and height content - imagine Pinterest on steroids (Pinterest only allows for variable height).

Live Demo

Please read comments in JavaScript for examples on how to use.

A live demo is available on my website - resize the window to see how it adapts: http://jasonmayes.com/projects/contentPlacer/

Browser Support

Key features

  • Fully responsive (up to the largest element width used).
  • Allows for variable width AND height content. All content must be a multiple of a base unit size.
  • Works with any type of responsive content (not just images).
  • Supports margins between content.
  • Works in all modern browsers.
  • Supports transitions for initial display and for fluid repositioning of content.
  • Requires no 3rd party libraries to work - pure native JavaScript.
  • Lightweight and efficient.
  • Fully customizable - all transitions / style is defined via CSS.

Why does this exist?

After a quick Google it seemed many other existing solutions required some third party library to work (jQuery), or were not as efficient as I wanted. I therefore decided to roll my own from a blank canvas to keep it as lightweight and efficient as possible.

Browser support

All popular browsers supported. Chrome, Firefox, Safari, Opera, Internet Explorer 9+ and I have tested on Android/iOS which seems to be fine too. Browser Support

Got suggestions? Feedback? Feature requests? Tell me!

Really, I like to hear feedback, and love to see what projects you have used it in. Feel free to give me a shoutout if you have used it. Talk to me: Via Google+, twitter, or my website.

Terms

Feel free to use in your own personal projects. I only ask you keep any disclaimers with my code (even if code is modified / minified) so others can find the original source should they wish to get updates or support. A link back / social media shout out is always appreciated to help others discover it (and for me to see what great things it is being used for) but not required :-)

If you plan to use in a commercial project please contact me first if you are unable to adhere to the above terms.

More Repositories

1

Real-Time-Person-Removal

Removing people from complex backgrounds in real time using TensorFlow.js in the web browser
JavaScript
5,173
star
2

Twitter-Post-Fetcher

Fetch your twitter posts without using the new Twitter 1.1 API. Pure JavaScript! By Jason Mayes
JavaScript
911
star
3

JS-Motion-Detection

A simple yet fast motion revealing algorithm using the live webcam feed
JavaScript
103
star
4

Tensor-Flow-on-Google-Compute-Engine

A simple script to set up GCE environment in Google Cloud so it is ready to run TensorFlow - an Open Source Software Library for Machine Intelligence
Shell
82
star
5

mdl-component-design-pattern

A design pattern that elegantly handles the registration of new components such that DOM upgrades are automatically performed on document load, as well as making it super easy to handle upgrades of elements that may be added after initial page load.
JavaScript
63
star
6

headless-chrome-nvidia-t4-gpu-support

Using headless Chrome on server side environments for true client side browser emulation with NVIDIA T4 GPUs for Web AI model testing or graphical workloads
Shell
60
star
7

doesVideoContain

JavaScript
48
star
8

Particle-Engine

A simple efficient configurable particle engine written in JavaScript using HTML5 canvas 2D which works on desktop and mobile by Jason Mayes
JavaScript
33
star
9

MP4-video-to-JPG-batch-converter

Specify a directory, this script will search it to find all MP4 videos, convert them to JPGs at a desired FPS and resize them to a given size. Super easy!
Shell
24
star
10

Retraining-TensorFlow-Classifier-Using-Video

Script to convert all MP4 videos in a zip archive to JPG frames at a desired FPS with unique names. It will then retrain the top layers of a binary image classifier using TensorFlow using these extracted images.
Shell
11
star
11

wsk-component-design-pattern

A design pattern that elegantly handles the registration of new components such that DOM upgrades are automatically performed on document load, as well as making it super easy to handle upgrades of elements that may be added after initial page load.
8
star
12

handlebars-helper

A helper component to make it super easy to use handlebars templates in a re-usable manner. Instead of defining script tags inline in your HTML to define templates you can instead write "template files" which will be bought in using AJAX.
JavaScript
7
star
13

Tessel-Multibox-Pointer

Use your Tessel with Google Compute Engine GPU instance running Darknet YOLO via a Node.js server to perform multibox detection over websockets. We can then point a servo at the object of interest and speak out what we see via the speaker.
C
7
star
14

Creative-Technologist-Toolkit

A small library written in Google Closure to do common things fast, useful for rapid prototyping in JavaScript.
JavaScript
4
star
15

dynamic-pages

HTML
1
star