jQuery Split Pane plugin

Overview

split-pane

jQuery Split Pane plugin

The plugin should work in IE8 and above as well as in Chrome, Safari and Firefox.

You can download split-pane.js and split-pane.css manually to you project or you can install with npm:

npm install split-pane

Split panes are initiated with

$(selector).splitPane();

Split pane component min-height and min-width are supported, and the component size can be set programmatically with

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

or

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

Only pixel values are supported.

Below is a basic example on how to use the plugin. Check out my blog post for some prettier examples.

You need to set up component widths and divider position using css, not as options to the JS splitPane function. The reason for this is that I like things to look good even before the JavaScript kicks in.

<!DOCTYPE html>
<html>
  <head>
		<title>Basic Example</title>
		<link rel="stylesheet" href="split-pane.css" />
		<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
		<script src="split-pane.js"></script>
		<style type="text/css">
			html, body {
				height: 100%;
				min-height: 100%;
				margin: 0;
				padding: 0;
			}
			.split-pane-divider {
				background: #aaa;
			}
			#left-component {
				width: 20em;
			}
			#my-divider {
				left: 20em; /* Same as left component width */
				width: 5px;
			}
			#right-component {
				left: 20em;  /* Same as left component width */
				margin-left: 5px;  /* Same as divider width */
			}
		</style>
		<script>
			$(function() {
				$('div.split-pane').splitPane();
			});
		</script>
	</head>
	<body>
		<div class="split-pane fixed-left">
			<div class="split-pane-component" id="left-component">
				This is the left component
			</div>
			<div class="split-pane-divider" id="my-divider"></div>
			<div class="split-pane-component" id="right-component">
				This is the right component
                <button onclick="$('div.split-pane').splitPane('firstComponentSize', 0);">Collapse first component</button>
			</div>
		</div>
	</body>
</html>
Comments
  • Remove unneeded z-index

    Remove unneeded z-index

    The .split-pane-component, .split-pane-divider-inner and .split-pane-divider have a z-index of 1 or 2. These values can interfere with the CSS of a project in which this plugin is used, in my case a modal with a z-index: 1;.

    In my opinion these values are not needed for this plugin to function. It looks like they are there for legacy reasons and are not needed anymore.

    @shagstrom would it makes sense to remove them? Or are they needed for a functioning split-pane?

    opened by caillou 7
  • Set splitter position dynamically

    Set splitter position dynamically

    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);
    }
    
    opened by brettz9 5
  • how to add click event handler to pane-divider?

    how to add click event handler to pane-divider?

    I want to hide the pane when user click to the divider. But code like this does not work:

    $( "#pane-divider" ).on('click', function(){
        $("#split-pane").splitPane('firstComponentSize', 0);"
    });
    

    The event handler is never reached. It seems the event propagation is stopped in your code.

    opened by kkozlik 4
  • 3 Column Layout

    3 Column Layout

    I'm looking to implement a 3 vertical column layout with your plugin. Similar to the vertical 2 column except with an additional 3rd vertical column.

    I haven't had much success. Is this possible? How would the HTML look like? Thanks.

    opened by tsquillario 4
  • Wrong placement of nested divider

    Wrong placement of nested divider

    I was trying to create the following layout:

    • Vertical divider with left component fixed
      • Left pane: Horizontal divider and top and bottom component widths in percent (30/70).
      • Right pane: Horizontal divider and top and bottom component widths in percent (65/35).

    In Chrome 35.0.1916.153, the horizontal divider within the left pane seems to not be resizable. It actually can be resized but the "handle" is in the wrong place (move pointer up and down will reveal its location).

    In Firefox 20.0 both horizontal dividers are initially misplaced.

    In both browsers, after the nested split pane has been resized once, the handle is in the right place.

    I'll attach my test html page.

    opened by anderskristensen 3
  • Scrolling assumes split-pane occupies full browser window?

    Scrolling assumes split-pane occupies full browser window?

    All your demos show the split-pane occupying the whole browser window. I didn't think much of it at the time. For my needs, I have a horizontal banner div at the top of the window and a horizontal split-pane taking up the remainder below. When the content of the split-pane requires scrolling, it never quite reaches the bottom of the content. It seems to be short by the same height as my banner. Any ideas?

    question 
    opened by janicki 3
  • Quick-understanding with CSS

    Quick-understanding with CSS

    Can I just suggest you make it clear on how to use this - when it comes to CSS. It seems like, given all your examples, you have to get the html/css all setup (maybe 100 lines) before you can use this.

    But you've written that this is your "preference" and that is all.

    Is it because it won't work any other way or you just prefer to create examples like this?

    Then looking at the examples, I have to study carefully to figure out what CSS is in your own library and what I need to introduce.

    opened by PandaWood 2
  • specify initial left pane width in pixels

    specify initial left pane width in pixels

    Is it possible to specify the initial left pane width in pixels ?

    I tried remarking 'right' in #left-component and #my-divider and replacing them with left:190px; but not sure how to change the 'width' in #right-component ?

    thx!

    opened by kofifus 2
  • UI on Firefox : resize splitter and it auto selected contain on right panel

    UI on Firefox : resize splitter and it auto selected contain on right panel

    I got this issue & find some solution. I think I should contribute to you fix it, maybe can help more developer.

    function removeAutoSelecteTextOnDocument() {
            //remove select text on document
            if (window.getSelection) {
                if (window.getSelection().empty) {  // Chrome
                    window.getSelection().empty();
                } else if (window.getSelection().removeAllRanges) {  // Firefox
                    window.getSelection().removeAllRanges();
                }
            } else if (document.selection) {  // IE?
                document.selection.empty();
            }
        }
    

    And call it on every handler, exp:

    function fixedLeftHandler(components, pageX) {
            var firstComponentMinWidth = minWidth(components.first),
                maxFirstComponentWidth = components.splitPane.offsetWidth - minWidth(components.last) - components.divider.offsetWidth,
                leftOffset = components.divider.offsetLeft - pageX;
            return function(event) {
                event.preventDefault && event.preventDefault();
                var left = newLeft(firstComponentMinWidth, maxFirstComponentWidth, leftOffset + pageXof(event));
                setLeft(components.first, components.divider, components.last, left + 'px');
                $(components.splitPane).resize();
                removeAutoSelecteTextOnDocument();
            };
        }
    
    opened by wallace57 2
  • window resize doesn't work for fixed-right

    window resize doesn't work for fixed-right

    This code doesn't work for fixed-right pane, and fixed-left works fine.

    $(document).on('resize', function() {
      console.log('resized')
    }).trigger('resize')
    

    I comments this line for work around event.stopPropagation();

    /**
     * A special event that will "capture" a resize event from the parent split-pane or window.
     * The event will NOT propagate to grandchildren.
     */
    $.event.special._splitpaneparentresize = {
        setup: function(data, namespaces) {
            var element = this,
                parent = $(this).parent().closest('.split-pane')[0] || window;
            $(this).data(SPLITPANERESIZE_HANDLER, function(event) {
                var target = event.target === document ? window : event.target;
                if (target === parent) {
                    event.type = "_splitpaneparentresize";
                    $.event.dispatch.apply(element, arguments);
                } else {
    
                    //event.stopPropagation();
                }
            });
            $(parent).on('resize', $(this).data(SPLITPANERESIZE_HANDLER));
        },
        teardown: function(namespaces) {
            var parent = $(this).parent().closest('.split-pane')[0] || window;
            $(parent).off('resize', $(this).data(SPLITPANERESIZE_HANDLER));
            $(this).removeData(SPLITPANERESIZE_HANDLER);
        }
    };
    
    opened by newghost 2
  • changing the divider width

    changing the divider width

    I'm not able to change the divider width. For example in percent-vertical.html in #my-divider { right: 80%; width: 5px; }

    I tried to change width to 1px but it did not seem to have any effect. Any help ?

    opened by kofifus 2
  • Problem after v0.9.2 when using iframe as component content

    Problem after v0.9.2 when using iframe as component content

    The resize events from the divider do not respond properly when dragging over top of the iframe after changes made between v0.9.2 and v0.9.3.

    Place the following in a file for an example:

    
    <!DOCTYPE html>
    <html>
    	<head>
    		<meta charset="utf-8">
    		<meta http-equiv="X-UA-Compatible" content="IE=edge">
    		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    		<title>Basic Example</title>
    		<link rel="stylesheet" href="../split-pane.css" />
    		<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
    		<script src="../split-pane.js"></script>
    		<style type="text/css">
    			html, body {
    				height: 100%;
    				min-height: 100%;
    				margin: 0;
    				padding: 0;
    			}
    			.split-pane-divider {
    				background: #aaa;
    			}
    			#left-component {
    				width: 20em;
    			}
    			#divider {
    				left: 20em; /* same as left component width */
    				width: 5px;
    			}
    			#right-component {
    				left: 20em;
    				margin-left: 5px; /* same as divider width */
    			}
    		</style>
    		<script>
    			$(function() {
    				$('div.split-pane').splitPane();
    				$('.split-pane-divider').on('click', function () {
    					console.log("click");
    				})
    			});
    		</script>
    	</head>
    	<body>
    		<div id="split-pane-1" class="split-pane fixed-left">
    			<div class="split-pane-component" id="left-component">
    				This is the left component
    			</div>
    			<div class="split-pane-divider" id="divider"></div>
    			<div class="split-pane-component" id="right-component">
    				<iframe src="https://www.w3schools.com" title="W3Schools Free Online Web Tutorials"></iframe>
    				<button onclick="$('div.split-pane').splitPane('firstComponentSize', 0);">Collapse first component</button>
    			</div>
    		</div>
    	</body>
    </html>
    
    opened by codesterother 0
  • Example -- Left Vertical Splitter

    Example -- Left Vertical Splitter

    1. Having a problem figuring out how to make the left and right panes set to percentage. As far as I can see, all of the examples which use left and right panes have fixed left panes. Would appreciate any help on this.
    2. Would like to save the positions of the splitters to a DB and reload them (per user). Thanks!
    opened by jeffparnau 0
  • Update jQuery

    Update jQuery

    There is a severity high vulnerability in jquery on which split-pane depends.

    $ yarn audit
    yarn audit v1.13.0
    ┌───────────────┬──────────────────────────────────────────────────────────────┐
    │ high          │ Cross-Site Scripting (XSS)                                   │
    ├───────────────┼──────────────────────────────────────────────────────────────┤
    │ Package       │ jquery                                                       │
    ├───────────────┼──────────────────────────────────────────────────────────────┤
    │ Patched in    │ >=3.0.0                                                      │
    ├───────────────┼──────────────────────────────────────────────────────────────┤
    │ Dependency of │ jquery                                                       │
    ├───────────────┼──────────────────────────────────────────────────────────────┤
    │ Path          │ jquery                                                       │
    ├───────────────┼──────────────────────────────────────────────────────────────┤
    │ More info     │ https://nodesecurity.io/advisories/328                       │
    └───────────────┴──────────────────────────────────────────────────────────────┘
    1 vulnerabilities found - Packages audited: 1
    Severity: 1 High
    Done in 0.41s.
    

    You should improve it by updating jquery to version 3.0.0 or later.

    opened by massongit 0
  • Filter out resize events if invisible

    Filter out resize events if invisible

    When splitPane becomes hidden its offsetWidth and offsetHeight is set to zero. This triggers resize handler. Then it calculates maxFirstComponentWidth as a difference between zero offsetWidth and other values, which produces and passes negative "left" value into setLeft. As a result the whole panel shifts beyond the screen after becoming visible again.

    opened by sergey-podolsky 0
  • cursor is changing when drag panel divider

    cursor is changing when drag panel divider

    Cursor twitches and changing style from col-resize to default when im dragging divider, especially it can be clearly seen in Internet Explorer 10/11.

    It is problem of version 0.9.3. In 0.9.2 all is fine.

    opened by Unrasend 2
Owner
Simon Hagström
Simon Hagström
An Obsidian plugin to add (prepend or append) specified content to a note (existing or new) without opening another pane.

Obsidian Note Content Pusher An Obsidian plugin to add (prepend or append) specified content to a note (existing or new) without opening another pane.

Henry Gustafson 21 Nov 6, 2022
An Obsidian Plugin that allows to export tables from a pane in reading mode to CSV files.

Obsidian Plugin "Table to CSV Exporter" This is my very first attempt in writing a plugin for Obsidian. I didn't even know TypeScript before (but Java

Stefan Wolfrum 26 Dec 27, 2022
A refined tool for exploring open-source projects on GitHub with a file tree, rich Markdown and image previews, multi-pane multi-tab layouts and first-class support for Ink syntax highlighting.

Ink codebase browser, "Kin" ?? The Ink codebase browser is a tool to explore open-source code on GitHub, especially my side projects written in the In

Linus Lee 20 Oct 30, 2022
Easily open daily notes and periodic notes in new pane; customize periodic notes background; quick append new line to daily notes.

Obsidian daily notes opener This plugin adds a command for opening daily notes in a new pane (so that a keyboard shortcut could be used!) and gives ex

Xiao Meng 16 Dec 26, 2022
BCash is an app to help you keep track of who you owe and who owes you money in an easy way. Split your tabs and more.

BCash BCash is an app to help you keep track of who you owe and who owes you money in an easy way. Split your tabs and more. Routes for develpment: lo

Cuitlahuac Maldonado 3 Aug 11, 2022
Unopinionated utilities for resizeable split views

Split Unopinionated utilities for resizeable split views. Zero Deps Tiny: Each is between 1-2kb gzipped. Fast: No overhead or attached window event li

Nathan Cahill 5.6k Dec 24, 2022
🏏 GitHub action to split your Git release tag into SemVer 2.0 parts

?? Git Tag Action GitHub action to split your Git release tag into SemVer 2.0 parts This is a simple action to split your git tag, usually for release

Noel 5 Oct 31, 2022
Split bills between friends ;)

SplitWise - FindCoder.io Hackathon Submission Full stack application to split bills among friends ;) Frontend : https://tripsplits.netlify.app/registe

Aarhan Khan 32 Dec 25, 2022
JQuery charCounter - jQuery Character Counter Plugin

jQuery Character Counter A jQuery based character counter for <input> and <textarea> HTML tags. What is this? This simple plugin allows you to add a c

mmmm_lemon 1 Aug 10, 2022
jQuery quick notification plugin. jQuery плагин быстрых уведомлений

Note: English translation by Google Translate Notific About Description: this is a jQuery plugin that helps you display notifications on your site. Li

Webarion 2 Nov 7, 2021
A variety of jQuery plugin patterns for jump starting your plugin development

jQuery Plugin Patterns So, you've tried out jQuery Boilerplate or written a few of your own plugins before. They work to a degree and are readable, bu

jQuery Boilerplate 1.6k Dec 31, 2022
This is a simple Image popup Jquery plugin. With a very simple configuration, you can show a popup on your webpage. By the way, this plugin works after page load.

Jquery-SingleImagePopup This is a simple Image popup Jquery plugin. With a very simple configuration, you can show a popup on your webpage. By the way

Rajan Karmaker 1 Aug 22, 2022
Jquery-actualizer - jQuery ajax actualizer

jQuery AJAX Actualizer Include jQuery & this plugin into your HTML file and use this js code: $('#target').actualizer('a'); On click at any A element,

Šimon (Simon) Rataj 1 Jul 28, 2020
jquery-input-mask-phone-number.js - A simple, easy jquery format phone number mask library

jquery-input-mask-phone-number A jQuery Plugin to make masks on input field to US phone format. Quick start 1. Add latest jQuery and jquery-input-mask

Raja Rama Mohan Thavalam 12 Aug 25, 2022
jQuery Star Rating Plugin

#jQuery Star Rating ##Overview The Star Rating Plugin is a plugin for the jQuery Javascript library that creates a non-obstrusive star rating control

Fyneworks 26 Nov 28, 2022
jQuery plugin to encourage strong user passwords

Naked Password¶ ↑ Simple jQuery plugin to improve security on passwords. Usage¶ ↑ Naked password is extremely easy to use. All thats needed is for you

Platform45 307 Nov 3, 2022
A jQuery plugin for doing client-side translations in javascript.

About jQuery-i18n is a jQuery plugin for doing client-side translations in javascript. It is based heavily on javascript i18n that almost doesn't suck

Dave Perrett 202 May 19, 2021
A jQuery plugin for creating exceptional footnotes.

bigfoot.js by Chris Sauve Bigfoot is a jQuery plugin that creates exceptional footnotes. Simply include the code on your pages and footnotes will be d

Chris Sauve 929 Nov 21, 2022
jQuery tabs plugin

English description | Описание на русском jQuery tabs plugin. Easy and well done tabs with many options and skin support Version: 1.0.2 Project page a

Denis Ineshin 83 Nov 27, 2022