react-grid-layout
Advanced tools
Comparing version 1.3.0 to 1.3.1
@@ -7,6 +7,6 @@ "use strict"; | ||
exports.calcGridColWidth = calcGridColWidth; | ||
exports.calcGridItemPosition = calcGridItemPosition; | ||
exports.calcGridItemWHPx = calcGridItemWHPx; | ||
exports.calcGridItemPosition = calcGridItemPosition; | ||
exports.calcWH = calcWH; | ||
exports.calcXY = calcXY; | ||
exports.calcWH = calcWH; | ||
exports.clamp = clamp; | ||
@@ -13,0 +13,0 @@ |
"use strict"; | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
@@ -14,3 +14,3 @@ Object.defineProperty(exports, "__esModule", { | ||
var _classnames = _interopRequireDefault(require("classnames")); | ||
var _clsx = _interopRequireDefault(require("clsx")); | ||
@@ -35,5 +35,5 @@ var _excluded = ["measureBeforeMount"]; | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } Object.defineProperty(subClass, "prototype", { value: Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }), writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
@@ -136,3 +136,3 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
return /*#__PURE__*/React.createElement("div", { | ||
className: (0, _classnames.default)(this.props.className, layoutClassName), | ||
className: (0, _clsx.default)(this.props.className, layoutClassName), | ||
style: this.props.style // $FlowIgnore ref types | ||
@@ -139,0 +139,0 @@ , |
"use strict"; | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
@@ -24,9 +24,9 @@ Object.defineProperty(exports, "__esModule", { | ||
var _classnames = _interopRequireDefault(require("classnames")); | ||
var _clsx = _interopRequireDefault(require("clsx")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } | ||
@@ -37,5 +37,5 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } Object.defineProperty(subClass, "prototype", { value: Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }), writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
@@ -517,3 +517,3 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
ref: this.elementRef, | ||
className: (0, _classnames.default)("react-grid-item", child.props.className, this.props.className, { | ||
className: (0, _clsx.default)("react-grid-item", child.props.className, this.props.className, { | ||
static: this.props.static, | ||
@@ -520,0 +520,0 @@ resizing: Boolean(this.state.resizing), |
"use strict"; | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
@@ -14,3 +14,3 @@ Object.defineProperty(exports, "__esModule", { | ||
var _classnames = _interopRequireDefault(require("classnames")); | ||
var _clsx = _interopRequireDefault(require("clsx")); | ||
@@ -39,5 +39,5 @@ var _utils = require("./utils"); | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } | ||
@@ -60,5 +60,5 @@ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } Object.defineProperty(subClass, "prototype", { value: Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }), writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
@@ -138,3 +138,3 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
oldDragItem: (0, _utils.cloneLayoutItem)(l), | ||
oldLayout: _this.state.layout | ||
oldLayout: layout | ||
}); | ||
@@ -152,3 +152,4 @@ | ||
cols = _this$props.cols, | ||
allowOverlap = _this$props.allowOverlap; | ||
allowOverlap = _this$props.allowOverlap, | ||
preventCollision = _this$props.preventCollision; | ||
var l = (0, _utils.getLayoutItem)(layout, i); | ||
@@ -167,3 +168,3 @@ if (!l) return; // Create placeholder (display only) | ||
var isUserAction = true; | ||
layout = (0, _utils.moveElement)(layout, l, x, y, isUserAction, _this.props.preventCollision, (0, _utils.compactType)(_this.props), cols, allowOverlap); | ||
layout = (0, _utils.moveElement)(layout, l, x, y, isUserAction, preventCollision, (0, _utils.compactType)(_this.props), cols, allowOverlap); | ||
@@ -682,3 +683,3 @@ _this.props.onDrag(layout, oldDragItem, l, placeholder, e, node); | ||
innerRef = _this$props9.innerRef; | ||
var mergedClassName = (0, _classnames.default)(layoutClassName, className); | ||
var mergedClassName = (0, _clsx.default)(layoutClassName, className); | ||
@@ -685,0 +686,0 @@ var mergedStyle = _objectSpread({ |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.default = exports.resizeHandleType = exports.resizeHandleAxesType = void 0; | ||
exports.resizeHandleType = exports.resizeHandleAxesType = exports.default = void 0; | ||
@@ -9,0 +9,0 @@ var _propTypes = _interopRequireDefault(require("prop-types")); |
"use strict"; | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
@@ -36,5 +36,5 @@ Object.defineProperty(exports, "__esModule", { | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } | ||
@@ -45,5 +45,5 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } Object.defineProperty(subClass, "prototype", { value: Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }), writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
@@ -50,0 +50,0 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } |
@@ -6,5 +6,5 @@ "use strict"; | ||
}); | ||
exports.findOrGenerateResponsiveLayout = findOrGenerateResponsiveLayout; | ||
exports.getBreakpointFromWidth = getBreakpointFromWidth; | ||
exports.getColsFromBreakpoint = getColsFromBreakpoint; | ||
exports.findOrGenerateResponsiveLayout = findOrGenerateResponsiveLayout; | ||
exports.sortBreakpoints = sortBreakpoints; | ||
@@ -11,0 +11,0 @@ |
@@ -7,28 +7,29 @@ "use strict"; | ||
exports.bottom = bottom; | ||
exports.childrenEqual = childrenEqual; | ||
exports.cloneLayout = cloneLayout; | ||
exports.modifyLayout = modifyLayout; | ||
exports.withLayoutItem = withLayoutItem; | ||
exports.cloneLayoutItem = cloneLayoutItem; | ||
exports.childrenEqual = childrenEqual; | ||
exports.fastPositionEqual = fastPositionEqual; | ||
exports.collides = collides; | ||
exports.compact = compact; | ||
exports.compactItem = compactItem; | ||
exports.compactType = compactType; | ||
exports.correctBounds = correctBounds; | ||
exports.fastPositionEqual = fastPositionEqual; | ||
exports.fastRGLPropsEqual = void 0; | ||
exports.getAllCollisions = getAllCollisions; | ||
exports.getFirstCollision = getFirstCollision; | ||
exports.getLayoutItem = getLayoutItem; | ||
exports.getFirstCollision = getFirstCollision; | ||
exports.getAllCollisions = getAllCollisions; | ||
exports.getStatics = getStatics; | ||
exports.modifyLayout = modifyLayout; | ||
exports.moveElement = moveElement; | ||
exports.moveElementAwayFromCollision = moveElementAwayFromCollision; | ||
exports.noop = void 0; | ||
exports.perc = perc; | ||
exports.setTopLeft = setTopLeft; | ||
exports.setTransform = setTransform; | ||
exports.setTopLeft = setTopLeft; | ||
exports.sortLayoutItems = sortLayoutItems; | ||
exports.sortLayoutItemsByColRow = sortLayoutItemsByColRow; | ||
exports.sortLayoutItemsByRowCol = sortLayoutItemsByRowCol; | ||
exports.sortLayoutItemsByColRow = sortLayoutItemsByColRow; | ||
exports.synchronizeLayoutWithChildren = synchronizeLayoutWithChildren; | ||
exports.validateLayout = validateLayout; | ||
exports.compactType = compactType; | ||
exports.noop = exports.fastRGLPropsEqual = void 0; | ||
exports.withLayoutItem = withLayoutItem; | ||
@@ -41,5 +42,5 @@ var _lodash = _interopRequireDefault(require("lodash.isequal")); | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } | ||
@@ -535,13 +536,19 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
if (movingUp) sorted = sorted.reverse(); | ||
var collisions = getAllCollisions(sorted, l); // There was a collision; abort | ||
var collisions = getAllCollisions(sorted, l); | ||
var hasCollisions = collisions.length > 0; // We may have collisions. We can short-circuit if we've turned off collisions or | ||
// allowed overlap. | ||
if (preventCollision && collisions.length) { | ||
if (!allowOverlap) { | ||
log("Collision prevented on ".concat(l.i, ", reverting.")); | ||
l.x = oldX; | ||
l.y = oldY; | ||
l.moved = false; | ||
} | ||
return layout; | ||
if (hasCollisions && allowOverlap) { | ||
// Easy, we don't need to resolve collisions. But we *did* change the layout, | ||
// so clone it on the way out. | ||
return cloneLayout(layout); | ||
} else if (hasCollisions && preventCollision) { | ||
// If we are preventing collision but not allowing overlap, we need to | ||
// revert the position of this element so it goes to where it came from, rather | ||
// than the user's desired location. | ||
log("Collision prevented on ".concat(l.i, ", reverting.")); | ||
l.x = oldX; | ||
l.y = oldY; | ||
l.moved = false; | ||
return layout; // did not change so don't clone | ||
} // Move each item that collides away from this element. | ||
@@ -548,0 +555,0 @@ |
// @flow | ||
import * as React from "react"; | ||
import PropTypes from "prop-types"; | ||
import classNames from "classnames"; | ||
import clsx from "clsx"; | ||
import type { ReactRef } from "../ReactGridLayoutPropTypes"; | ||
@@ -91,3 +91,3 @@ | ||
<div | ||
className={classNames(this.props.className, layoutClassName)} | ||
className={clsx(this.props.className, layoutClassName)} | ||
style={this.props.style} | ||
@@ -94,0 +94,0 @@ // $FlowIgnore ref types |
@@ -19,3 +19,3 @@ // @flow | ||
} from "./ReactGridLayoutPropTypes"; | ||
import classNames from "classnames"; | ||
import clsx from "clsx"; | ||
import type { Element as ReactElement, Node as ReactNode } from "react"; | ||
@@ -638,3 +638,3 @@ | ||
ref: this.elementRef, | ||
className: classNames( | ||
className: clsx( | ||
"react-grid-item", | ||
@@ -641,0 +641,0 @@ child.props.className, |
@@ -5,3 +5,3 @@ // @flow | ||
import isEqual from "lodash.isequal"; | ||
import classNames from "classnames"; | ||
import clsx from "clsx"; | ||
import { | ||
@@ -256,3 +256,3 @@ bottom, | ||
oldDragItem: cloneLayoutItem(l), | ||
oldLayout: this.state.layout | ||
oldLayout: layout | ||
}); | ||
@@ -279,3 +279,3 @@ | ||
let { layout } = this.state; | ||
const { cols, allowOverlap } = this.props; | ||
const { cols, allowOverlap, preventCollision } = this.props; | ||
const l = getLayoutItem(layout, i); | ||
@@ -302,3 +302,3 @@ if (!l) return; | ||
isUserAction, | ||
this.props.preventCollision, | ||
preventCollision, | ||
compactType(this.props), | ||
@@ -666,3 +666,7 @@ cols, | ||
const { layerX, layerY } = e.nativeEvent; | ||
const droppingPosition = { left: layerX / transformScale, top: layerY / transformScale, e }; | ||
const droppingPosition = { | ||
left: layerX / transformScale, | ||
top: layerY / transformScale, | ||
e | ||
}; | ||
@@ -764,3 +768,3 @@ if (!this.state.droppingDOMNode) { | ||
const mergedClassName = classNames(layoutClassName, className); | ||
const mergedClassName = clsx(layoutClassName, className); | ||
const mergedStyle = { | ||
@@ -767,0 +771,0 @@ height: this.containerHeight(), |
@@ -472,12 +472,19 @@ // @flow | ||
const collisions = getAllCollisions(sorted, l); | ||
const hasCollisions = collisions.length > 0; | ||
// There was a collision; abort | ||
if (preventCollision && collisions.length) { | ||
if (!allowOverlap) { | ||
log(`Collision prevented on ${l.i}, reverting.`); | ||
l.x = oldX; | ||
l.y = oldY; | ||
l.moved = false; | ||
} | ||
return layout; | ||
// We may have collisions. We can short-circuit if we've turned off collisions or | ||
// allowed overlap. | ||
if (hasCollisions && allowOverlap) { | ||
// Easy, we don't need to resolve collisions. But we *did* change the layout, | ||
// so clone it on the way out. | ||
return cloneLayout(layout); | ||
} else if (hasCollisions && preventCollision) { | ||
// If we are preventing collision but not allowing overlap, we need to | ||
// revert the position of this element so it goes to where it came from, rather | ||
// than the user's desired location. | ||
log(`Collision prevented on ${l.i}, reverting.`); | ||
l.x = oldX; | ||
l.y = oldY; | ||
l.moved = false; | ||
return layout; // did not change so don't clone | ||
} | ||
@@ -718,9 +725,11 @@ | ||
// FIXME clone not really necessary here | ||
layout.push(cloneLayoutItem({ | ||
w: 1, | ||
h: 1, | ||
x: 0, | ||
y: bottom(layout), | ||
i: String(child.key) | ||
})); | ||
layout.push( | ||
cloneLayoutItem({ | ||
w: 1, | ||
h: 1, | ||
x: 0, | ||
y: bottom(layout), | ||
i: String(child.key) | ||
}) | ||
); | ||
} | ||
@@ -727,0 +736,0 @@ } |
{ | ||
"name": "react-grid-layout", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "A draggable and resizable grid layout with responsive breakpoints, for React.", | ||
@@ -38,3 +38,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"classnames": "2.3.1", | ||
"clsx": "^1.1.1", | ||
"lodash.isequal": "^4.0.0", | ||
@@ -41,0 +41,0 @@ "prop-types": "^15.0.0", |
@@ -322,6 +322,8 @@ # React-Grid-Layout | ||
// If true, grid can be placed one over the other. | ||
// If set, implies `preventCollision`. | ||
allowOverlap: ?boolean = false, | ||
// If true, grid items won't change position when being | ||
// dragged over. | ||
// dragged over. If `allowOverlap` is still false, | ||
// this simply won't allow one to drop on an existing object. | ||
preventCollision: ?boolean = false, | ||
@@ -555,3 +557,3 @@ | ||
If you have a bug to report, please reproduce the bug in [CodeSandbox](https://codesandbox.io/s/5wy3rz5z1x?module=%2Fsrc%2FShowcaseLayout.js) to help | ||
If you have a bug to report, please reproduce the bug in [CodeSandbox](https://codesandbox.io/s/staging-bush-3lvt7?file=/src/ShowcaseLayout.js) to help | ||
us easily isolate it. | ||
@@ -572,3 +574,3 @@ | ||
- [x] Min/max w/h per item | ||
- [ ] Resizable handles on other corners | ||
- [x] Resizable handles on other corners | ||
- [ ] Configurable w/h per breakpoint |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
794718
0
100
6356
574
34
+ Addedclsx@^1.1.1
- Removedclassnames@2.3.1
- Removedclassnames@2.3.1(transitive)