Skip to content
This repository has been archived by the owner on Sep 8, 2020. It is now read-only.

Commit

Permalink
feat(handle): added option to enable a handle on a splitbar for dragging
Browse files Browse the repository at this point in the history
  • Loading branch information
widmoser committed Feb 18, 2016
1 parent 5e23ee9 commit d5df922
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 9 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ Default: `false`

Like `disableToggle` above but only removes the arrows on mobile devices (max-device-width: 480px).

### showHandle

Type: `Boolean`
Default: `false`

Whether to show a handle in the middle of a splitbar. If toggle is enabled at the same time, the handle is shown between
the two toggle buttons. The handle has the css class `.ui-splitbar-handle`.

## Child Attributes

Expand Down
19 changes: 17 additions & 2 deletions src/ui-layout.css
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,13 @@
overflow-x: hidden;
}

.ui-layout-column > .ui-splitbar > a:not(.ui-splitbar-handle-container),
.ui-layout-row > .ui-splitbar > a:not(.ui-splitbar-handle-container) {
cursor: pointer;
}

.ui-layout-column > .ui-splitbar > a,
.ui-layout-row > .ui-splitbar > a {
cursor: pointer;
text-align: center;
font-size: 16px;
color: #aaa;
Expand Down Expand Up @@ -127,8 +131,19 @@
margin-top: 0.45em;
}

.ui-splitbar-handle {
width: 10px;
height: 2px;
box-shadow: inset 0 0 0 32px, 0 -6px, 0 6px;
margin: 12px 0;
}

/* Allow disabling of icons */
.no-toggle .ui-splitbar-icon {
.no-toggle .ui-splitbar-toggle {
display: none;
}

.no-handle .ui-splitbar-handle {
display: none;
}

Expand Down
16 changes: 10 additions & 6 deletions src/ui-layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ angular.module('ui.layout', [])
if (opts.disableMobileToggle) {
$element.addClass('no-mobile-toggle');
}
if (!opts.showHandle) {
$element.addClass('no-handle');
}

// Initial global size definition
opts.sizes = opts.sizes || [];
Expand Down Expand Up @@ -422,7 +425,7 @@ angular.module('ui.layout', [])
el = splitter.element[0].children[0];
} else {
splitter = ctrl.containers[index - 1];
el = splitter.element[0].children[1];
el = splitter.element[0].children[2];
}

$timeout(function(){
Expand Down Expand Up @@ -688,7 +691,7 @@ angular.module('ui.layout', [])

//icon <a> elements
var prevButton = angular.element(element.children()[0]);
var afterButton = angular.element(element.children()[1]);
var afterButton = angular.element(element.children()[2]);

//icon <span> elements
var prevIcon = angular.element(prevButton.children()[0]);
Expand All @@ -714,7 +717,7 @@ angular.module('ui.layout', [])

if(previousSplitbar !== null) {
prevSplitbarBeforeButton = angular.element(previousSplitbar.element.children()[0]);
prevSplitbarAfterButton = angular.element(previousSplitbar.element.children()[1]);
prevSplitbarAfterButton = angular.element(previousSplitbar.element.children()[2]);
}

if(ctrl.isUsingColumnFlow) {
Expand Down Expand Up @@ -774,7 +777,7 @@ angular.module('ui.layout', [])

if(nextSplitbar !== null) {
nextSplitbarBeforeButton = angular.element(nextSplitbar.element.children()[0]);
nextSplitbarAfterButton = angular.element(nextSplitbar.element.children()[1]);
nextSplitbarAfterButton = angular.element(nextSplitbar.element.children()[2]);
}

if(ctrl.isUsingColumnFlow) {
Expand Down Expand Up @@ -947,8 +950,9 @@ angular.module('ui.layout', [])
var children = parent.children();
var index = ctrl.indexOfElement(element);
var splitbar = angular.element('<div ui-splitbar>' +
'<a><span class="ui-splitbar-icon"></span></a>' +
'<a><span class="ui-splitbar-icon"></span></a>' +
'<a><span class="ui-splitbar-icon ui-splitbar-toggle"></span></a>' +
'<a class="ui-splitbar-handle-container"><span class="ui-splitbar-icon ui-splitbar-handle"></span></a>' +
'<a><span class="ui-splitbar-icon ui-splitbar-toggle"></span></a>' +
'</div>');
if(0 < index && !ctrl.hasSplitbarBefore(scope.container)) {
angular.element(children[index-1]).after(splitbar);
Expand Down
2 changes: 1 addition & 1 deletion test/layout-scenar.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ function splitMoveTests(description, startEvent, moveEvent, endEvent) {

beforeEach(function() {
toggleBeforeButton = $splitbar.children()[0];
toggleAfterButton = $splitbar.children()[1];
toggleAfterButton = $splitbar.children()[2];
});

it('should exist', function() {
Expand Down

0 comments on commit d5df922

Please sign in to comment.