Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set splitter position dynamically #14

Closed
brettz9 opened this issue Jun 7, 2015 · 5 comments
Closed

Set splitter position dynamically #14

brettz9 opened this issue Jun 7, 2015 · 5 comments

Comments

@brettz9
Copy link

brettz9 commented Jun 7, 2015

I was wondering whether you'd be open to allowing setting the splitter position dynamically. My use case for this is remembering the last splitter position of the user.

I'm currently doing this outside of your code via the following:

var pane = $('div.split-pane').children('.split-pane-divider');

function triggerSplitterDrop (vDrop) {
    var offset = pane.offset();
    var ev = {
        which: 1,
        pageX: offset.left,
        pageY: offset.top
    };
    var mdEvent = $.Event('mousedown', ev);

    ev.pageY = vDrop || offset.top;
    var mmEvent = $.Event('mousemove', ev);
    var muEvent = $.Event('mouseup', ev);

    pane.trigger(mdEvent);
    pane.trigger(mmEvent);
    pane.trigger(muEvent);
}
@arturparkhisenko
Copy link
Contributor

👍

@arturparkhisenko
Copy link
Contributor

updated version (fix to ev.originalEvent):

function triggerSplitterDrop(pane, vDrop) {
    var offset = pane.offset();
    var ev = {
        which: 1,
        pageX: offset.left,
        pageY: offset.top
    };
    ev.originalEvent = ev;
    var mdEvent = $.Event('mousedown', ev);
    ev.pageY = vDrop || offset.top;
    ev.originalEvent = ev;
    var mmEvent = $.Event('mousemove', ev);
    var muEvent = $.Event('mouseup', ev);
    pane.trigger(mdEvent);
    pane.trigger(mmEvent);
    pane.trigger(muEvent);
}

and call it:

var myPane = $('div.split-pane').children('.split-pane-divider');
triggerSplitterDrop(myPane);

@shagstrom
Copy link
Owner

Yes, that would be a good idea. Other people have requested that too. Their use case being collapsing one component. I will implement it soon - I hope :) I'm thinking of a syntax something like this: $('div.split-pane').splitPane('first-component', 20);

@shagstrom
Copy link
Owner

In v 0.6.0 one can do this

$(selector).splitPane('firstComponentSize', 0);"

or

$(selector).splitPane('lastComponentSize', 100);"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@brettz9 @arturparkhisenko @shagstrom and others