diff options
author | Ethan Romba <ethan.romba@parivedasolutions.com> | 2012-07-10 10:21:56 -0700 |
---|---|---|
committer | Mike Sherov <mike.sherov@gmail.com> | 2012-11-09 09:48:50 -0500 |
commit | 6e0a0553ce85997e4f37597800b440b1e4371b5b (patch) | |
tree | 4078c23dec17ae81d561a3b5b23874726e1c1da2 /ui/jquery.ui.resizable.js | |
parent | 48e0aa0fd2782380931af43abb5bb92b73ebe4ad (diff) | |
download | jquery-ui-6e0a0553ce85997e4f37597800b440b1e4371b5b.tar.gz jquery-ui-6e0a0553ce85997e4f37597800b440b1e4371b5b.zip |
Resizable: Grid now respects min/max dimensions. Fixed #8435 - grid does not respect min/max dimensions
Diffstat (limited to 'ui/jquery.ui.resizable.js')
-rw-r--r-- | ui/jquery.ui.resizable.js | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/ui/jquery.ui.resizable.js b/ui/jquery.ui.resizable.js index c2ad28716..c701c06be 100644 --- a/ui/jquery.ui.resizable.js +++ b/ui/jquery.ui.resizable.js @@ -769,25 +769,39 @@ $.ui.plugin.add("resizable", "grid", { resize: function() { var that = $(this).data("resizable"), o = that.options, cs = that.size, os = that.originalSize, op = that.originalPosition, a = that.axis; o.grid = typeof o.grid == "number" ? [o.grid, o.grid] : o.grid; - var ox = Math.round((cs.width - os.width) / (o.grid[0]||1)) * (o.grid[0]||1), oy = Math.round((cs.height - os.height) / (o.grid[1]||1)) * (o.grid[1]||1); + var gridX = (o.grid[0]||1), gridY = (o.grid[1]||1), + ox = Math.round((cs.width - os.width) / gridX) * gridX, oy = Math.round((cs.height - os.height) / gridY) * gridY, + newWidth = os.width + ox, newHeight = os.height + oy, + isMaxWidth = o.maxWidth && (o.maxWidth < newWidth), isMaxHeight = o.maxHeight && (o.maxHeight < newHeight), + isMinWidth = o.minWidth && (o.minWidth > newWidth), isMinHeight = o.minHeight && (o.minHeight > newHeight); + + if (isMinWidth) { + newWidth = newWidth + gridX; + } + if (isMinHeight) { + newHeight = newHeight + gridY; + } + if (isMaxWidth) { + newWidth = newWidth - gridX; + } + if (isMaxHeight) { + newHeight = newHeight - gridY; + } if (/^(se|s|e)$/.test(a)) { - that.size.width = os.width + ox; - that.size.height = os.height + oy; - } - else if (/^(ne)$/.test(a)) { - that.size.width = os.width + ox; - that.size.height = os.height + oy; + that.size.width = newWidth; + that.size.height = newHeight; + } else if (/^(ne)$/.test(a)) { + that.size.width = newWidth; + that.size.height = newHeight; that.position.top = op.top - oy; - } - else if (/^(sw)$/.test(a)) { - that.size.width = os.width + ox; - that.size.height = os.height + oy; + } else if (/^(sw)$/.test(a)) { + that.size.width = newWidth; + that.size.height = newHeight; that.position.left = op.left - ox; - } - else { - that.size.width = os.width + ox; - that.size.height = os.height + oy; + } else { + that.size.width = newWidth; + that.size.height = newHeight; that.position.top = op.top - oy; that.position.left = op.left - ox; } |