ducksboard / gridster.js

gridster.js is a jQuery plugin that makes building intuitive draggable layouts from elements spanning multiple columns
http://gridster.net/
MIT License
6.03k stars 1.2k forks source link

Stop resize after placeholder resize #299

Closed ciaranj closed 10 years ago

ciaranj commented 10 years ago

Previously the resize.stop callback was being called before the widget had reached the final size that Gridster would make it (the widget continues to grows up and until it matches the placeholder size after releasing the drag)

This change pushes the resize.stop callback to the last possible moment where the size of the widget the callback receives is more likely to be correct.

The second commit is just a regen of the distributables, feel free to drop that commit :)

P.s. Gridster is ace thank you!

ciaranj commented 10 years ago

Mmmm-kay, so this approach still doesn't work :( What I found I had to do to ensure that my widths + heights were 'correct' on at least the final resize callback was pass the width + height of the $resize_preview_holder element to the resize.start, resize.stop and resize.resize callbacks. This seems to work. Anyone want to see a PR on that ?

artem-karpenko commented 10 years ago

This would be a cool fix, our old code uses setTimeout to trail actual size

ciaranj commented 10 years ago

Yeah, I used a setTimeout for a while, but it ended up being 'jumpy' at the end :/

artem-karpenko commented 10 years ago

So have you found issues with this PR? I've applied your fix and it seems to work fine.

ciaranj commented 10 years ago

Well, with the PR in its current form it didn't really work too well :/ The version I'm actually using over in

https://github.com/ciaranj/chartled/commit/46fa4f1b4f47b9e528bcf9acbec2ff609593bf6b#diff-078273c651a64b5bc46ce1498e27c739

Works a lot better where I pass back the placeholder element and use those sizes instead. I left this PR around to discuss whether there was interest in that approach (As it would change the interface, it might be frowned upon)

vieron commented 10 years ago

Thanks! Merged here e21f63a05a539f5c611eb49cd6861b1e38b36531.