react-gallery-layout
Advanced tools
+14
-3
@@ -11,2 +11,6 @@ require('./sass/index.sass') | ||
| import ResizeSensor from './src/resize' | ||
| import curry from 'curry' | ||
| const add = curry(function add(a, b){ return a + b }) | ||
| const sub = curry(function (b, a) { return a - b }) | ||
| function array(thing) { | ||
@@ -41,3 +45,3 @@ const length = thing.length | ||
| function getWidth (rects) { | ||
| return rects.reduce((width, rect) => { | ||
| const max = rects.reduce((width, rect) => { | ||
| if (rect.x === undefined) { | ||
@@ -47,3 +51,9 @@ return width | ||
| return Math.max(width, rect.x + rect.width) | ||
| }, 0) | ||
| }, 0); | ||
| return max - rects.reduce((width, rect) => { | ||
| if (rect.x === undefined) { | ||
| return width | ||
| } | ||
| return Math.min(width, rect.x) | ||
| }, max) | ||
| } | ||
@@ -201,3 +211,4 @@ | ||
| const offset = (state.size.width - width) / 2 | ||
| rects.forEach(rect => { rect.x += offset }) | ||
| const f = rtl ? sub(offset) : add(offset) | ||
| rects.forEach(rect => { rect.x = f(rect.x) }) | ||
| } | ||
@@ -204,0 +215,0 @@ } else { |
+2
-1
| { | ||
| "name": "react-gallery-layout", | ||
| "version": "0.2.3", | ||
| "version": "0.2.4", | ||
| "description": "React.js based gallery component", | ||
@@ -21,2 +21,3 @@ "main": "index.js", | ||
| "css-element-queries": "^0.3.2", | ||
| "curry": "^1.2.0", | ||
| "react": "^15.4.1", | ||
@@ -23,0 +24,0 @@ "react-dom": "^15.4.1", |
+1
-1
@@ -1,2 +0,2 @@ | ||
| import binpack, {sorters} from 'binpack-2d' | ||
| import binpack from 'binpack-2d' | ||
| import {rows, columns, grid} from 'card-layouts' | ||
@@ -3,0 +3,0 @@ const layouts = {rows, columns, grid} |
+7
-3
@@ -20,5 +20,5 @@ # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
| binpack-2d@^1.3.1: | ||
| version "1.3.1" | ||
| resolved "https://registry.yarnpkg.com/binpack-2d/-/binpack-2d-1.3.1.tgz#a478df05af17c85fa0ca0ab545c2fbed88c883a6" | ||
| binpack-2d@^1.3.2: | ||
| version "1.3.2" | ||
| resolved "https://registry.yarnpkg.com/binpack-2d/-/binpack-2d-1.3.2.tgz#357d486b8d3288caadde9459045da802fc6e967d" | ||
| dependencies: | ||
@@ -45,2 +45,6 @@ array.prototype.find "^2.0.1" | ||
| curry@^1.2.0: | ||
| version "1.2.0" | ||
| resolved "https://registry.yarnpkg.com/curry/-/curry-1.2.0.tgz#9e6dd289548dba7e653d5ae3fe903fe7dfb33af2" | ||
| define-properties@^1.1.2: | ||
@@ -47,0 +51,0 @@ version "1.1.2" |
24167
2.09%532
1.92%8
14.29%+ Added
+ Added