resizestop event issue
Hi,
After resizing an element I need to catch the new width / height. For that purpose I'm using the resizestop event but I couldn't find the new values in here (only the old ones)
It seems to be that the values are updated somewhere after this event , and I only can get the new values on the next resize event (which of course is not suitable)
Thanks
Why don't you use onchange event? An onchange handler receives all affected items.
This seems to have changed between 0.2.2 and the current 0.2.3-dev. Formerly, the new values were accessible, now the old values are returned.
Using onchange is cumbersome as it contains details about all items that changed because of a resize, rather than just the one of interest.
I guess I agree with m5c in this. It is good to support each event type with it's relevant data, specially for complex scenarios.
I played with 0.2.3-dev a bit more, and I was wrong, the new values do get sent. (I have some other code that has a different outcome from 0.2.2, still investigating that.)
The "ui" object contains the originalSize and size properties that give you what you need:
$('.grid-stack').on('resizestop', function (event, ui) { ... }
I swear I examined both objects and found the old values in both. But mistakes can happen! I will re-check that tonight ;)
It could probably be because of animation. Please check it with and without.
I can confirm what lopezcjf is saying.
$('.grid-stack').on('resizestop', function (event, ui) {
console.debug(ui.element[0].attributes.getNamedItem("data-gs-width"));
console.debug(ui.element[0].attributes.getNamedItem("data-gs-width").value);
});
first console output is: data-gs-width="1" second console output is: 12
First console output is the actual new width of widget and second is the old value. I am not using animation.
See also issue #159, where there is a fix for this posted.
Closing, as @derekm's code has been merged. @lopezcjf please reopen if you're having a problem still.