Only run checks for drag and resize if x, y, width, or height have changed at least one cell width/height.

This commit is contained in:
Dylan Weiss 2016-08-21 10:33:24 -04:00
parent 215a6f16a2
commit 5cf92a3c62
6 changed files with 47 additions and 25 deletions

18
dist/gridstack.all.js vendored

File diff suppressed because one or more lines are too long

View file

@ -5,7 +5,7 @@
* gridstack.js may be freely distributed under the MIT license.
* @preserve
*/
!function(a){if("function"==typeof define&&define.amd)define(["jquery","lodash","gridstack","jquery-ui/data","jquery-ui/disable-selection","jquery-ui/focusable","jquery-ui/form","jquery-ui/ie","jquery-ui/keycode","jquery-ui/labels","jquery-ui/jquery-1-7","jquery-ui/plugin","jquery-ui/safe-active-element","jquery-ui/safe-blur","jquery-ui/scroll-parent","jquery-ui/tabbable","jquery-ui/unique-id","jquery-ui/version","jquery-ui/widget","jquery-ui/widgets/mouse","jquery-ui/widgets/draggable","jquery-ui/widgets/droppable","jquery-ui/widgets/resizable"],a);else if("undefined"!=typeof exports){try{jQuery=require("jquery")}catch(a){}try{_=require("lodash")}catch(a){}try{GridStackUI=require("gridstack")}catch(a){}a(jQuery,_,GridStackUI)}else a(jQuery,_,GridStackUI)}(function(a,b,c){/**
!function(a){if("function"==typeof define&&define.amd)define(["jquery","lodash","gridstack","jquery-ui/data","jquery-ui/disable-selection","jquery-ui/focusable","jquery-ui/form","jquery-ui/ie","jquery-ui/keycode","jquery-ui/labels","jquery-ui/jquery-1-7","jquery-ui/plugin","jquery-ui/safe-active-element","jquery-ui/safe-blur","jquery-ui/scroll-parent","jquery-ui/tabbable","jquery-ui/unique-id","jquery-ui/version","jquery-ui/widget","jquery-ui/widgets/mouse","jquery-ui/widgets/draggable","jquery-ui/widgets/droppable","jquery-ui/widgets/resizable"],a);else if("undefined"!=typeof exports){try{jQuery=require("jquery")}catch(b){}try{_=require("lodash")}catch(b){}try{GridStackUI=require("gridstack")}catch(b){}a(jQuery,_,GridStackUI)}else a(jQuery,_,GridStackUI)}(function(a,b,c){/**
* @class JQueryUIGridStackDragDropPlugin
* jQuery UI implementation of drag'n'drop gridstack plugin.
*/

17
dist/gridstack.js vendored
View file

@ -482,6 +482,11 @@
node.width = width;
node.height = height;
node.lastTriedX = x;
node.lastTriedY = y;
node.lastTriedWidth = width;
node.lastTriedHeight = height;
node = this._prepareNode(node, resizing);
this._fixCollisions(node);
@ -1095,10 +1100,18 @@
return;
}
}
if (!self.grid.canMoveNode(node, x, y, width, height)) {
// width and height are undefined if not resizing
var lastTriedWidth = typeof width !== 'undefined' ? width : node.lastTriedWidth;
var lastTriedHeight = typeof height !== 'undefined' ? height : node.lastTriedHeight;
if (!self.grid.canMoveNode(node, x, y, width, height) ||
(node.lastTriedX === x && node.lastTriedY === y &&
node.lastTriedWidth === lastTriedWidth && node.lastTriedHeight === lastTriedHeight)) {
return;
}
node.lastTriedX = x;
node.lastTriedY = y;
node.lastTriedWidth = width;
node.lastTriedHeight = height;
self.grid.moveNode(node, x, y, width, height);
self._updateContainerHeight();
};

16
dist/gridstack.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -482,6 +482,11 @@
node.width = width;
node.height = height;
node.lastTriedX = x;
node.lastTriedY = y;
node.lastTriedWidth = width;
node.lastTriedHeight = height;
node = this._prepareNode(node, resizing);
this._fixCollisions(node);
@ -1095,10 +1100,18 @@
return;
}
}
if (!self.grid.canMoveNode(node, x, y, width, height)) {
// width and height are undefined if not resizing
var lastTriedWidth = typeof width !== 'undefined' ? width : node.lastTriedWidth;
var lastTriedHeight = typeof height !== 'undefined' ? height : node.lastTriedHeight;
if (!self.grid.canMoveNode(node, x, y, width, height) ||
(node.lastTriedX === x && node.lastTriedY === y &&
node.lastTriedWidth === lastTriedWidth && node.lastTriedHeight === lastTriedHeight)) {
return;
}
node.lastTriedX = x;
node.lastTriedY = y;
node.lastTriedWidth = width;
node.lastTriedHeight = height;
self.grid.moveNode(node, x, y, width, height);
self._updateContainerHeight();
};