react-grid-layout-horizontal-compact
Advanced tools
Comparing version
@@ -150,29 +150,19 @@ 'use strict'; | ||
function compactItem(compareWith, l, compactType, cols) { | ||
var compactV = compactType === 'vertical'; | ||
var compactH = compactType === 'horizontal'; | ||
if (compactV) { | ||
l.y = Math.min(bottom(compareWith), l.y); | ||
// First pass: compact Vertically | ||
l.y = Math.min(bottom(compareWith), l.y); | ||
l.x = 0; | ||
// Move the element up as far as it can go without colliding. | ||
while (l.y > 0 && !getFirstCollision(compareWith, l)) { | ||
l.y--; | ||
} | ||
} else if (compactH) { | ||
// Move the element left as far as it can go without colliding. | ||
while (l.x > 0 && !getFirstCollision(compareWith, l)) { | ||
l.x--; | ||
} | ||
// Move the element up as far as it can go without colliding. | ||
while (l.y > 0 && !getFirstCollision(compareWith, l)) { | ||
l.y--; | ||
} | ||
// Move it down, and keep moving it down if it's colliding. | ||
// Move it right, and keep moving it right if it's colliding. | ||
// if we run out of space horizontally, move to a new column | ||
var collides = void 0; | ||
while (collides = getFirstCollision(compareWith, l)) { | ||
if (compactH) { | ||
l.x = collides.x + collides.w; | ||
} else { | ||
l.y = collides.y + collides.h; | ||
} | ||
l.x = collides.x + collides.w; | ||
// Since we can't grow without bounds horizontally, if we've overflown, let's move it down and try again. | ||
if (compactH && l.x + l.w > cols) { | ||
l.x = cols - l.w; | ||
if (l.x + l.w > cols) { | ||
l.x = 0; | ||
l.y++; | ||
@@ -179,0 +169,0 @@ } |
{ | ||
"name": "react-grid-layout-horizontal-compact", | ||
"version": "0.14.5", | ||
"version": "0.14.6", | ||
"description": "A draggable and resizable grid layout with responsive breakpoints, for React.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# React-Grid-Layout | ||
[](https://travis-ci.org/STRML/react-grid-layout) | ||
[](https://www.npmjs.org/package/react-grid-layout) | ||
[]() | ||
### ATTN: | ||
This is a temporary fork, waiting for the official lib to either merge [PR #534](https://github.com/STRML/react-grid-layout/pull/534) or to implement STH like [Issue #157](https://github.com/STRML/react-grid-layout/issues/157). | ||
It will be deprecated as soon as these are fixed. DO NOT USE, DO NOT DEPEND ON THIS. I warned you. | ||
======== | ||
React-Grid-Layout is a grid layout system much like [Packery](http://packery.metafizzy.co/) or | ||
@@ -8,0 +10,0 @@ [Gridster](http://gridster.net), for React. |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
410
0.49%0
-100%163079
-0.35%1662
-0.6%