Opened 11 years ago
Last modified 10 years ago
#8000 open feature
Sortable: Allow the dimensions of sortable items to be changed in a start event
Reported by: | ferdyp | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | 2.0.0 |
Component: | ui.sortable | Version: | 1.8.16 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Because the 'start' event is triggered late, any changes to an elements height are not applied to the ui-sortable-helper, which at the time the event triggers has already been created.
Therefor you can not make changes to an elements height before dragging, as the helper will preserve the old height.
The issue is easily fixed by triggering the start-event before creating the helper. Patch:
--- jquery.ui.sortable.js Tue Jan 10 17:12:25 2012 +++ jquery.ui.sortable.js Tue Jan 10 17:12:25 2012 @@ -126,5 +126,2 @@
- Call callbacks
- this._trigger("start", event, this._uiHash());
We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
@@ -211,2 +208,5 @@
this.overflowOffset = this.scrollParent.offset();
+ + Call callbacks + this._trigger("start", event, this._uiHash());
Change History (10)
comment:2 Changed 11 years ago by
And a code example; http://jsbin.com/ivuwak/2
Note when dragging 'Item 2' it's height remains as it was, while it's childs have already been hidden.
comment:3 Changed 11 years ago by
Of course an easier, safer and quicker fix would be to introduce a new beforeStart-event.
comment:5 Changed 11 years ago by
This seems like a potentially breaking change. It will be addressed in the rewrite.
comment:6 Changed 11 years ago by
Type: | enhancement → feature |
---|
comment:7 Changed 10 years ago by
Milestone: | 1.9.0 → 2.0.0 |
---|
comment:8 Changed 10 years ago by
Status: | new → open |
---|
comment:9 Changed 10 years ago by
Summary: | start-event is triggered too late → Sortable: Allow the dimensions of sortable items to be changed in a start event |
---|
comment:10 Changed 10 years ago by
Here's a reduced test case against master: http://jsfiddle.net/tj_vantoll/Lwz7z/.
Can't edit my issue, but here is the patch in a decent format;