You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When resizing a widget, the dimensions snap to the grid after the handle is released. This is great. :)
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?
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!
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.
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 - @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.
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?
Activity
pySilver commentedon Jun 25, 2015
for a quickfix you can use your caclulation inside setTimeout call with appropriate timeout. More reliable would be using debouncing technique.
danielandross commentedon Jul 30, 2015
+1 for fixing this issue.
derekm commentedon 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 commentedon Aug 6, 2015
I've dug into it some more. For whatever reason, the
resizestopfunctions here$._data($(".grid-stack")[0], "events")fire first, then thestopfunction here$($("."+$(".grid-stack").data("gridstack").opts.item_class).get(0)).data("ui-resizable").optionsfires second (aka,GridStack.prototype._prepare_element'son_end_moving).This firing behavior seems backwards to me. I would expect the
.grid-stack-item'sstopto fire before.grid-stack'sresizestop, but that isn't the case. I'm trying to determine why this is the case, but the code is a bit murky.derekm commentedon 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_movingin_prepare_elementas an event callback instead of passing it as an options callback. I may issue a pull request to fix this.tazeroualti commentedon Nov 27, 2015
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 commentedon Feb 22, 2016
@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 commentedon 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 commentedon Jul 14, 2017
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).