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:1 Changed 11 years ago by ferdyp

Can't edit my issue, but here is the patch in a decent format;

--- 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());
 
Last edited 11 years ago by ferdyp (previous) (diff)

comment:2 Changed 11 years ago by ferdyp

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 ferdyp

Of course an easier, safer and quicker fix would be to introduce a new beforeStart-event.

comment:4 Changed 10 years ago by ferdyp

Any feedback (or action) would be appreciatied.

comment:5 Changed 10 years ago by Scott González

This seems like a potentially breaking change. It will be addressed in the rewrite.

comment:6 Changed 10 years ago by Scott González

Type: enhancementfeature

comment:7 Changed 10 years ago by Scott González

Milestone: 1.9.02.0.0

comment:8 Changed 10 years ago by Jörn Zaefferer

Status: newopen

comment:9 Changed 10 years ago by tj.vantoll

Summary: start-event is triggered too lateSortable: Allow the dimensions of sortable items to be changed in a start event

comment:10 Changed 10 years ago by tj.vantoll

Here's a reduced test case against master: http://jsfiddle.net/tj_vantoll/Lwz7z/.

Note: See TracTickets for help on using tickets.