Skip to content

Fire onresizestop after complete resizing #159

Closed

Description

@amelzer

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?

Activity

  1. pySilver commented on Jun 25, 2015

    @pySilver

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

  2. danielandross commented on Jul 30, 2015

    @danielandross

    +1 for fixing this issue.

  3. derekm commented on Aug 6, 2015

    @derekm

    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!

  4. derekm commented on Aug 6, 2015

    @derekm

    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.

  5. derekm commented on Aug 6, 2015

    @derekm

    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.

  6. tazeroualti commented on Nov 27, 2015

    @tazeroualti

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

  7. radiolips commented on Feb 22, 2016

    @radiolips
    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.

  8. lwwells commented on Jan 17, 2017

    @lwwells

    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?

  9. garthgoodson commented on Jul 14, 2017

    @garthgoodson

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions