-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Resizing issue #1530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resizing issue #1530
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you for doing this! but minRow + 100 is a big no. Ping me if you need more help on fixing right way.
src/utils.ts
Outdated
| /** @internal */ | ||
| static updateScrollResize(event: MouseEvent, el: HTMLElement, distance: number): void { | ||
| let scrollEl = this.getScrollParent(el); | ||
| if (scrollEl === null) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!scrollEl ) return;
src/utils.ts
Outdated
| scrollEl.scrollBy({ behavior: 'smooth', top: event.clientY - distance}); | ||
| } | ||
|
|
||
| if (bottom) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else if (bottom)
src/gridstack-dd.ts
Outdated
|
|
||
| // Saving `minRow` and adding new ones for resizing | ||
| minRow = this.opts.minRow; | ||
| this.opts.minRow = this.getRow() + 100; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
big no no - don't arbitrary add 100 rows!
we should only add 1 extra row (when computing the needed rows) IFF the item you are resizing/moving is at the bottom (node.y+node.h). don't need to mod minRow for this...
src/utils.ts
Outdated
| } | ||
| } | ||
|
|
||
| /** @internal */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put a real comment on your code. seems reasonable given we do something similar (though quite different code. I will have to diff into the scroll as I didn't write that)
| /** @internal */ | ||
| private temporalRect: Rect; | ||
| /** @internal */ | ||
| private scrollY: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need that in JQ version as well ?
src/h5/dd-resizable.ts
Outdated
| private _resizeStart(event: MouseEvent): DDResizable { | ||
| this.originalRect = this.el.getBoundingClientRect(); | ||
| const scrollEl = Utils.getScrollParent(this.el); | ||
| this.scrollY = scrollEl === null ? 0 : scrollEl.scrollTop; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.scrollY = scrollEl ? scrollEl.scrollTop : 0;
src/h5/dd-resizable.ts
Outdated
| private _getChange(event: MouseEvent, dir: string): Rect { | ||
| const oEvent = this.startEvent; | ||
| const scrollEl = Utils.getScrollParent(this.el); | ||
| const scrolled = scrollEl === null ? 0 : (scrollEl.scrollTop - this.scrollY); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar change
src/h5/dd-resizable.ts
Outdated
| /** @internal */ | ||
| private _resizeStart(event: MouseEvent): DDResizable { | ||
| this.originalRect = this.el.getBoundingClientRect(); | ||
| const scrollEl = Utils.getScrollParent(this.el); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cache this since you need it in all 3 methods and continuously, or does it change over time ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changes over time. When there is no scroll because the layout is small scrollEl is null and eventually when the layout grows returns the scrollable element.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, so you could scrollEl = scrollEl || Utils.getScrollParent(this.el) and cache it once it appears, unless it changes values ?
quick looking it appears to go up recursively so maybe it could be different elements over time... so maybe not.
|
Thanks for the tips @adumesny. I need some help with the placeholder and the view of the item while resizing. There is two case that I'm not sure how to solve. When the item is at the bottom and the mouse pointer goes out of the |
|
I'll take a look in the next couple days... I just spend entire weekend re-writing collision so need to take a break from gridstack |
|
sorry, taking a look now. I had to fix some Safari mac issues and released I also tweaked on we do resizing (event handling really). |
adumesny
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that looks reasonable (minor doc comments). Can you update to the latest dev code so I can push it in ?
I need to cherry pick as well to verify it works. Have you tried how tat affects the JQ version as well ?
| } else if (el.scrollHeight > el.clientHeight) { | ||
| returnEl = el; | ||
| if (el === null) return document.documentElement; | ||
| const style = getComputedStyle(el); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is getComputedStyle() better than checking the simple el.scrollHeight > el.clientHeight because you want to remember what parent MIGHT scroll later ? (in case you don't already scroll ?) - please add comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, also with el.scrollHeight > el.clientHeight sometimes is selecting a non scrollable parent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interesting. didn't think that would be possible... but I realize the call you have return the first that could scroll which is safer anyway... but always return the doc as least, which might not scroll so it should return NULL and have that be handled ideally...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly, the best option would be returning NULL when there isn't a scrollable parent but in this case, we need to prevent gridstack to continue growing.
I was using the example float.html to check my changes. I think in this example the ideal would be that gridstack stops growing when there is no more page because the element that is scrolling is the document not the container that wraps gridstack.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And we need to manually prevent gridstack to grow because:
In my case, I have two screens one on top of another and I have the browser with the webpage with gridstack on the screen above.

When I try to resize or drag and drop an item to the bottom my mouse continue on the screen bellow so gridstack still growing even when the page can't scroll. Once I stop there is no scrollable parent so the documentElement is resized to wrap everything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well we have a maxRow to prevent grid from growing past that size, but you are saying that if none of the parents can scroll (by default divs will auto scroll unless you have overflow: hidden or something) then we should stop growing so we don't clip, which makes sense... Looks like you are checking for overflow | overflow-y for and auto or scroll
you don't need 2 screens to test this. browser smaller than full screen will do that too...
if you want to take a stab at it that would be great. _prepareDragDropByNode() should cache if we can not v-scroll and prevent move/size past the max somehow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll take a look at this over the week (probably weekend, I'm quite busy right now) :)
| /** @internal */ | ||
| private _resizeStart(event: MouseEvent): DDResizable { | ||
| this.originalRect = this.el.getBoundingClientRect(); | ||
| this.scrollEl = Utils.getScrollParent(this.el); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reset this in destroy()
No problem at all. Thanks for merging and sorry for the comments, I can open a PR to add some comments if you want. |
|
no need, I took care of it I believe. thanks for fixing this issue! |



Description
As discussed in #1001 the resizing with scrolling is not working.
I'm trying to solve it here but I'm having some troubles. Now is working fine but I'm resizing the layout adding some rows on
resizestartbecause when while resizing an item there is a back and force with the number of cells creating a strange behaviour.Checklist
yarn test)