Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Bug in SC.SplitView #578

orest-stasyk opened this Issue Aug 12, 2011 · 7 comments


None yet
4 participants

If one of views in split view is disabled - mouse up event doesn't work.


ialexi commented Aug 12, 2011

Is this on the old or new SplitView? In sproutcore/experimental/split_view there is a new SplitView that works a lot better.

Sent from Alex's iPhone

On Aug 12, 2011, at 2:56 AM, orest-stasyk reply@reply.github.com wrote:

If one of views in split view is disabled - mouse up event doesn't work.

Reply to this email directly or view it on GitHub:


unicolet commented Sep 24, 2011

How can I use the experimental/split_view in my project?


ialexi commented Sep 26, 2011

The docs are in the source for now, unfortunately, but the gist is:


:required => [:sproutcore, (any other parts here), "sproutcore/experimental/split_view"]

In your SplitView:

mySplitView: SC.SplitView.design({
    // specify childViews instead of using topLeft/bottomRight
    // NOTE: you are not limited to two views anymore!
    childViews: 'yourLeftSide yourRightSide'.w(),

    // notice: mix in SC.SplitChild
    yourLeftSide: SC.View.design(SC.SplitChild, {
        // specify size for the one that should remain static as the split view resizes,
        // leave it out for the other side:
        size: 200,

        minimumSize: 150,
        maximumSize: 250,

        ... your stuff here ...

    yourRightSide: SC.View.design(SC.SplitChild, {
        ... your stuff here ...

On Sep 24, 2011, at 11:49 AM, unicolet wrote:

How can I use the experimental/split_view in my project?

Reply to this email directly or view it on GitHub:
#578 (comment)


unicolet commented Sep 27, 2011

Thanks it's working. Like the possibility to have more than one sub view.
Since you were so helpful, I'm going to abuse your patience: is it possible to programmatically minimize/collapse a subview?

Thanks a lot,


ialexi commented Sep 27, 2011

Programmatically collapsing a subview is both easy and hard. It is easy to actually do, but perhaps difficult to conceptualize :)

The tricky bit is to realize that SplitView thinks primarily in terms of subview position, not subview size. So, if you are collapsing the left child, you are really moving the next child all the way to the left.

To collapse the right child, you are moving the rightmost child all the way to the right (where its size would be 0).

For instance, all you need to do in principal is:

splitView.adjustPositionForChild(splitView.whateverYouNamedRightChild, 0)

But there's a catch: the left child has a minimum size! It can't collapse to 0. :(

SplitView has a built-in way around this, though you can also code your own. I'll discuss both briefly.

Built-in way

  • set canCollapse to YES on the child.
  • set collapseAtSize to something (even 0 if you'd like) on the child

Now the child has an alternative minimum size that, if it goes past, it collapses to size 0.

Custom way

If you only want programatic collapsing, you can either override, or supply in a delegate, the splitViewConstrainSizeForChild method. For instance:

splitViewConstrainSizeForChild: function(splitView, child, size) {
  // you'd set isProgramaticallyCollapsed, or whatever you want to call the boolean,
  // in your collapsing method
  if (child.isProgramaticallyCollapsed) return 0;

  // in a delegate:
  return splitView.splitViewConstrainSizeForChild(splitView, child, size);

  // if you overrode it:

I hope that helps!

Also, if you'd like to try to add this support directly to SplitView--perhaps a collapse() and expand() method on SplitChild itself--feel free to give it a shot. I'd be glad to assist.


unicolet commented Oct 15, 2011

I gave it a shot and added a collapseLeft/Right and expandLeft/Right, you can check it out here:



publickeating commented Sep 11, 2013

The experimental version of SC.SplitView is now the default version in 1.10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment