Does draggable's stack option have to be a complex hash?

192 views
Skip to first unread message

Richard D. Worth

unread,
Mar 2, 2009, 9:19:51 AM3/2/09
to jquery...@googlegroups.com
I was taking a look at the Draggable dosc and saw the stack option:

stack
http://docs.jquery.com/UI/API/1.7/Draggable#option-stack
"Controls the z-Index of the defined group (key 'group' in the hash, accepts jQuery selector) automatically, always brings to front the dragged item. Very useful in things like window managers. Optionally, a 'min' key can be set, so the zIndex cannot go below that value."

Code example:
$('.selector').draggable({ stack: { group: 'products', min: 50 } });

What is the need for a user having to specify a min option? Imagine you have 3 elements that are all stacking together. I'm can see them either swapping three z-Index values around as you drag them:

100, 101, 102
100, 102, 101
102, 101, 100

or increasing each time

100, 101, 102
100, 103, 102
104, 103, 102

But I'm trying to imagine a scenario where the z-Index would decrease, then requiring the user to specify a min. Also, what's the expected behavior if the user doesn't specify a min, as the default value for stack is false?

Without this stack.min, could this option be a simple string instead of a hash? Like so

$('.selector').draggable({ stack: 'products' });

but that also makes me think, why isn't this a selector, instead of a group name? Then you could even specify stack: true which could be equivalent to stack: '.ui-draggable'. This would be consistent with the snap option:

snap
http://docs.jquery.com/UI/API/1.7/Draggable#option-snap
"If set to a selector or to true (equivalent to '.ui-draggable'), the draggable will snap to the edges of the selected elements when near an edge of the element."

Thoughts?

- Richard

Paul Bakaus

unread,
Mar 2, 2009, 9:33:00 AM3/2/09
to jquery...@googlegroups.com
On Mon, Mar 2, 2009 at 3:19 PM, Richard D. Worth <rdw...@gmail.com> wrote:
I was taking a look at the Draggable dosc and saw the stack option:

stack
http://docs.jquery.com/UI/API/1.7/Draggable#option-stack
"Controls the z-Index of the defined group (key 'group' in the hash, accepts jQuery selector) automatically, always brings to front the dragged item. Very useful in things like window managers. Optionally, a 'min' key can be set, so the zIndex cannot go below that value."

Code example:
$('.selector').draggable({ stack: { group: 'products', min: 50 } });

What is the need for a user having to specify a min option? Imagine you have 3 elements that are all stacking together. I'm can see them either swapping three z-Index values around as you drag them:

100, 101, 102
100, 102, 101
102, 101, 100

or increasing each time

100, 101, 102
100, 103, 102
104, 103, 102

But I'm trying to imagine a scenario where the z-Index would decrease, then requiring the user to specify a min. Also, what's the expected behavior if the user doesn't specify a min, as the default value for stack is false?

I actually had the min zIndex in there for situations where no z-index has been set before on those elements. I guess we could remove it if it is properly documented that these elements need to have some z-index beforehand.
 


Without this stack.min, could this option be a simple string instead of a hash? Like so

$('.selector').draggable({ stack: 'products' });

but that also makes me think, why isn't this a selector, instead of a group name? Then you could even specify stack: true which could be equivalent to stack: '.ui-draggable'. This would be consistent with the snap option:

snap
http://docs.jquery.com/UI/API/1.7/Draggable#option-snap
"If set to a selector or to true (equivalent to '.ui-draggable'), the draggable will snap to the edges of the selected elements when near an edge of the element."

Thoughts?

I think a selector would be better here as well, agreed.
 


- Richard






--
Paul Bakaus
UI Architect
--
http://paulbakaus.com
http://www.linkedin.com/in/paulbakaus

Scott González

unread,
Mar 18, 2009, 10:38:25 PM3/18/09
to jquery...@googlegroups.com

paolochiodi

unread,
Mar 24, 2009, 12:18:24 PM3/24/09
to jQuery UI Development
On 2 Mar, 15:33, Paul Bakaus <paul.bak...@googlemail.com> wrote:
>
> I actually had the min zIndex in there for situations where no z-index has
> been set before on those elements. I guess we could remove it if it is
> properly documented that these elements need to have some z-index
> beforehand.
>

in fact, the need for a preset z-index if not specifying a min value
is unclear. I was going to open a ticket just before I read this post
why is it needed? can't be assumed min = 0 as default?

>
>
>
> I think a selector would be better here as well, agreed.
>

me too, but assuming min = 0

>
> Paul Bakaus

Paolo Chiodi
http://www.linkedin.com/in/paolochiodi

Paul Bakaus

unread,
Aug 22, 2009, 4:01:47 AM8/22/09
to jquery...@googlegroups.com
Fixed/Implemented now in r3105.
--
Paul Bakaus
UI Architect @ smart.fm
Reply all
Reply to author
Forward
0 new messages