Skip to content
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

Fire onresizestop after complete resizing #159

Closed
amelzer opened this issue Jun 9, 2015 · 9 comments
Closed

Fire onresizestop after complete resizing #159

amelzer opened this issue Jun 9, 2015 · 9 comments

Comments

@amelzer
Copy link

amelzer commented Jun 9, 2015

When resizing a widget, the dimensions snap to the grid after the handle is released. This is great. :)

screenshot from 2015-06-09 11 56 49

However, it seems that onresizestop() is triggered before that process is finished so if you try to get the widgets dimension, you get them 'wrong'.
Is there a way to get an event that is triggered after the full resizing process?

@pySilver
Copy link

for a quickfix you can use your caclulation inside setTimeout call with appropriate timeout. More reliable would be using debouncing technique.

@danielandross
Copy link

+1 for fixing this issue.

@derekm
Copy link

derekm commented Aug 6, 2015

I came here to open an issue saying the same thing.

I would like to get el.dataset.gsHeight and el.dataset.gsWidth in my resizestop event handler, but it fires early before the data-gs-height and data-gs-width attributes have been updated.

I'm digging through gridstack.js to locate the source of this out-of-order event or race condition. Any pointers as to where to make the fix would be helpful!

Thanks!

@derekm
Copy link

derekm commented Aug 6, 2015

I've dug into it some more. For whatever reason, the resizestop functions here $._data($(".grid-stack")[0], "events") fire first, then the stop function here $($("."+$(".grid-stack").data("gridstack").opts.item_class).get(0)).data("ui-resizable").options fires second (aka, GridStack.prototype._prepare_element's on_end_moving).

This firing behavior seems backwards to me. I would expect the .grid-stack-item's stop to fire before .grid-stack's resizestop, but that isn't the case. I'm trying to determine why this is the case, but the code is a bit murky.

@derekm
Copy link

derekm commented Aug 6, 2015

This bug report (http://bugs.jqueryui.com/ticket/9580) helped me to identify the problem. Basically, callbacks inside options structures are not event callbacks, they are pure callbacks. The event is fired and all event callbacks are executed, then all options callbacks are executed. The solution is to bind on_end_moving in _prepare_element as an event callback instead of passing it as an options callback. I may issue a pull request to fix this.

@tazeroualti
Copy link

Hi all,
I 'm new user of the Gridstack, I have the same problem as amelzer. Is there a new fix of this issue ?

@radiolips
Copy link
Member

@tazeroualti - @derekm was kind enough to build a fix for this, which has since been merged into gridstack v0.2.5-dev. Though this build is not necessarily stable, it incorporates many bug fixes, and I'd recommend giving it a go to see if it fixes your issue.

@lwwells
Copy link

lwwells commented Jan 17, 2017

This morning I downloaded the releases zip which includes gridstack 0.2.6. It appears as though the same issue exists. I was under the impression that his had been merged in...what am I missing? Is still in dev only?

@garthgoodson
Copy link

I have this issue in 0.3.0. Looks like the fix went into the 0.2.x branch, and the code in the 0.3.0 is sufficiently different.

I'm using the gsresizestop callback and need to use a settimeout to get the new height/width using jquery (not ideal).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants