All Projects → axyz → Perfect Layout

axyz / Perfect Layout

Licence: mit
Image layout generator based on linear partitioning

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Perfect Layout

diorama
An image layout algorithm
Stars: ✭ 17 (-94.55%)
Mutual labels:  gallery, layout, images
Silentbox
A lightbox inspired Vue.js component.
Stars: ✭ 196 (-37.18%)
Mutual labels:  images, gallery
Photo view
📸 Easy to use yet very customizable zoomable image widget for Flutter, Photo View provides a gesture sensitive zoomable widget. Photo View is largely used to show interacive images and other stuff such as SVG.
Stars: ✭ 1,280 (+310.26%)
Mutual labels:  images, gallery
react-simple-image-viewer
Simple image viewer component for React
Stars: ✭ 44 (-85.9%)
Mutual labels:  gallery, images
React Native Image Gallery
Pure JavaScript image gallery component for iOS and Android with high-performance and native feeling in mind
Stars: ✭ 601 (+92.63%)
Mutual labels:  images, gallery
Jquery.lazy
A lightweight, fast, feature-rich, powerful and highly configurable delayed content, image and background lazy loading plugin for jQuery & Zepto.
Stars: ✭ 965 (+209.29%)
Mutual labels:  images, jquery-plugin
MediaSliderView
Pure java based, highly customizable media slider gallery supporting both images and videos for android.
Stars: ✭ 85 (-72.76%)
Mutual labels:  gallery, images
V Img
Stars: ✭ 400 (+28.21%)
Mutual labels:  images, gallery
Floral
Minimal design gallery app for Android.
Stars: ✭ 23 (-92.63%)
Mutual labels:  gallery, images
hes-gallery
Light, dependency free, responsive gallery script
Stars: ✭ 27 (-91.35%)
Mutual labels:  gallery, images
xGallerify
A lightweight, responsive, smart gallery based on jQuery
Stars: ✭ 52 (-83.33%)
Mutual labels:  gallery, jquery-plugin
React Grid Gallery
Justified image gallery component for React
Stars: ✭ 571 (+83.01%)
Mutual labels:  images, gallery
Nanogallery2
a modern photo / video gallery and lightbox [JS library]
Stars: ✭ 488 (+56.41%)
Mutual labels:  images, gallery
Covering Bad
A simple jQuery Plugin for covering an item with another item by dragging it
Stars: ✭ 75 (-75.96%)
Mutual labels:  images, jquery-plugin
Vue Gallery
📷 Responsive and customizable image and video gallery, carousel and lightbox, optimized for both mobile and desktop web browsers.
Stars: ✭ 405 (+29.81%)
Mutual labels:  images, gallery
React Slideshow
A react component for slideshow supporting slide, fade and zoom
Stars: ✭ 201 (-35.58%)
Mutual labels:  images, gallery
Fotorama
A simple, stunning, powerful jQuery gallery.
Stars: ✭ 1,567 (+402.24%)
Mutual labels:  jquery-plugin, gallery
Collectionviewpaginglayout
a simple but highly customizable paging layout for UICollectionView.
Stars: ✭ 947 (+203.53%)
Mutual labels:  layout, gallery
django-content-gallery
A Django application allows to attach a collection of images to objects of any model in any app
Stars: ✭ 18 (-94.23%)
Mutual labels:  gallery, images
image-uploader
Simple Drag & Drop image uploader plugin to static forms, without using AJAX
Stars: ✭ 70 (-77.56%)
Mutual labels:  gallery, jquery-plugin

Perfect Layout

Medium Article

DEMO

given an array of images in the form

{
  data: WATHEVER_YOU_WANT,
  src: "path/to/image.jpg",
  ratio: 1.5
}

returns an array of images in the form

{
  data: WATHEVER_YOU_WANT,
  src: "path/to/image.jpg",
  width: WIDTH,
  height: HEIGHT
}

where WIDTH and HEIGHT are the dimensions that image must have to fit the layout.

Usage

on node

$ npm install --save perfect-layout

and

var perfectLayout = require('perfect-layout')

while on the browser you can just

<script src="perfectLayout.min.js"></script>

then

var perfectRows = perfectLayout(photos, width, height, {
  // default options
  margin: 0
});

Options

  • margin: [number] If you are going to use a css margin for your images you need to specify it here as well, so that the layout will adapt to scale down the images accordingly.

Motivations

This was inspired by chromatic.io galleries and I want to credit the @crispymtn team for the original implementation.

This version aim to be more lightweight using a greedy algorithm instead of the optimal one and also leave to the user the responsability to choose how to manipulate the DOM accordingly to the returned array.

Example jQuery plugin

for convenience a jquery plugin is included for a basic usage.

assuming that a global window.photos array exists as specified above

<div id="gallery"></div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.js"></script>
<script src="jquery.perfectLayout.min.js"></script>

<script>
$(document).ready(function() {
  $('#gallery').perfectGallery(photos);

  $(window).resize(function() {
    $('#gallery').perfectGallery(photos);
  });
});

</script>

N.B. Please note that this is only an example on how to use the perfectLayout function. The jQuery plugin is not to be used in production as it do not provide any crossbrowser optimization, at the time of writing it should however correctly work on the latest chrome and firefox browsers on linux.

For custom behaviour give a look at the jqueryPlugin.js and use it as a starting point to generate the desired DOM nodes.

the data field can be used to populate the images with any needed metadata you may need and is probably a good idea to provide it from your backend.

Changelog

[v1.2.0]

Changed

  • using breakPointPartition thanks to @GreenGremlin

[v1.1.1]

Changed

  • using BST based linear partitioning instead of greedy one
  • huge speed improvement
  • the resulting set is now optimal

Fixed

  • the partition will now keep the same order as the input array
  • the layout should now be equal to the chromatic.io one in all the cases

[v1.1.0]

Added

  • margin option

[v1.0.0]

Initial Release

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].