Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fcbecd4

Browse files
authored
Merge pull request gridstack#1607 from adumesny/develop
H5: resize from left side can move item right
2 parents 275e6c5 + 56493d9 commit fcbecd4

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

doc/CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ Change log
5656
- fix [1600](https://github.com/gridstack/gridstack.js/issues/1600) height too small with `cellHeight:auto` loading in 1 column. Now detect we load at 1 column and size accordingly (default 'auto' could make big 700x700 cells, so explicit px might still be wanted)
5757
- fix [1538](https://github.com/gridstack/gridstack.js/issues/1538) loading nested into small size and sizing back up
5858
- fix [1604](https://github.com/gridstack/gridstack.js/issues/1604) nested grid resizing fix
59+
- fix [1599](https://github.com/gridstack/gridstack.js/issues/1599) resize from left side can move item right
5960

6061
## 3.2.0 (2021-1-25)
6162

spec/e2e/html/1330-maxw-left-resize.html renamed to spec/e2e/html/1330-1559-left-resize-maxW-and-others.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@
1515
<script type="text/javascript">
1616
let grid = GridStack.init({resizable: { handles: 'sw, se, w, e, s' }});
1717
addEvents(grid);
18-
grid.load([{x: 2, y: 0, maxW: 1, content: 'max 1'}, {x: 5, y: 0, maxW: 2, content: 'max 2'}]);
18+
grid.load([
19+
{x: 2, y: 0, maxW: 1, content: 'max 1'},
20+
{x: 5, y: 0, maxW: 2, content: 'max 2'},
21+
{x: 7, y: 0, content: 'normal'},
22+
]);
1923
</script>
2024
</body>
2125
</html>

src/h5/dd-resizable.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
232232
top: this.originalRect.top - this.scrolled
233233
};
234234

235-
const offsetH = event.clientX - oEvent.clientX;
236-
const offsetV = event.clientY - oEvent.clientY;
235+
const offsetX = event.clientX - oEvent.clientX;
236+
const offsetY = event.clientY - oEvent.clientY;
237237

238238
if (dir.indexOf('e') > -1) {
239239
newRect.width += event.clientX - oEvent.clientX;
@@ -242,12 +242,12 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
242242
newRect.height += event.clientY - oEvent.clientY;
243243
}
244244
if (dir.indexOf('w') > -1) {
245-
newRect.width -= offsetH;
246-
newRect.left += offsetH;
245+
newRect.width -= offsetX;
246+
newRect.left += offsetX;
247247
}
248248
if (dir.indexOf('n') > -1) {
249-
newRect.height -= offsetV;
250-
newRect.top += offsetV
249+
newRect.height -= offsetY;
250+
newRect.top += offsetY
251251
}
252252
const reshape = this._getReShapeSize(newRect.width, newRect.height);
253253
if (newRect.width !== reshape.width) {
@@ -267,9 +267,9 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
267267

268268
/** @internal */
269269
private _getReShapeSize(oWidth: number, oHeight: number): Size {
270-
const maxWidth = this.option.maxWidth || oWidth;
270+
const maxWidth = this.option.maxWidth || Number.MAX_SAFE_INTEGER;
271271
const minWidth = this.option.minWidth || oWidth;
272-
const maxHeight = this.option.maxHeight || oHeight;
272+
const maxHeight = this.option.maxHeight || Number.MAX_SAFE_INTEGER;
273273
const minHeight = this.option.minHeight || oHeight;
274274
const width = Math.min(maxWidth, Math.max(minWidth, oWidth));
275275
const height = Math.min(maxHeight, Math.max(minHeight, oHeight));

0 commit comments

Comments
 (0)