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

Commit d5df922

Browse files
committed
feat(handle): added option to enable a handle on a splitbar for dragging
1 parent 5e23ee9 commit d5df922

File tree

4 files changed

+35
-9
lines changed

4 files changed

+35
-9
lines changed

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,13 @@ Default: `false`
100100

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

103+
### showHandle
104+
105+
Type: `Boolean`
106+
Default: `false`
107+
108+
Whether to show a handle in the middle of a splitbar. If toggle is enabled at the same time, the handle is shown between
109+
the two toggle buttons. The handle has the css class `.ui-splitbar-handle`.
103110

104111
## Child Attributes
105112

src/ui-layout.css

+17-2
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,13 @@
7373
overflow-x: hidden;
7474
}
7575

76+
.ui-layout-column > .ui-splitbar > a:not(.ui-splitbar-handle-container),
77+
.ui-layout-row > .ui-splitbar > a:not(.ui-splitbar-handle-container) {
78+
cursor: pointer;
79+
}
80+
7681
.ui-layout-column > .ui-splitbar > a,
7782
.ui-layout-row > .ui-splitbar > a {
78-
cursor: pointer;
7983
text-align: center;
8084
font-size: 16px;
8185
color: #aaa;
@@ -127,8 +131,19 @@
127131
margin-top: 0.45em;
128132
}
129133

134+
.ui-splitbar-handle {
135+
width: 10px;
136+
height: 2px;
137+
box-shadow: inset 0 0 0 32px, 0 -6px, 0 6px;
138+
margin: 12px 0;
139+
}
140+
130141
/* Allow disabling of icons */
131-
.no-toggle .ui-splitbar-icon {
142+
.no-toggle .ui-splitbar-toggle {
143+
display: none;
144+
}
145+
146+
.no-handle .ui-splitbar-handle {
132147
display: none;
133148
}
134149

src/ui-layout.js

+10-6
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ angular.module('ui.layout', [])
5252
if (opts.disableMobileToggle) {
5353
$element.addClass('no-mobile-toggle');
5454
}
55+
if (!opts.showHandle) {
56+
$element.addClass('no-handle');
57+
}
5558

5659
// Initial global size definition
5760
opts.sizes = opts.sizes || [];
@@ -422,7 +425,7 @@ angular.module('ui.layout', [])
422425
el = splitter.element[0].children[0];
423426
} else {
424427
splitter = ctrl.containers[index - 1];
425-
el = splitter.element[0].children[1];
428+
el = splitter.element[0].children[2];
426429
}
427430

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

689692
//icon <a> elements
690693
var prevButton = angular.element(element.children()[0]);
691-
var afterButton = angular.element(element.children()[1]);
694+
var afterButton = angular.element(element.children()[2]);
692695

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

715718
if(previousSplitbar !== null) {
716719
prevSplitbarBeforeButton = angular.element(previousSplitbar.element.children()[0]);
717-
prevSplitbarAfterButton = angular.element(previousSplitbar.element.children()[1]);
720+
prevSplitbarAfterButton = angular.element(previousSplitbar.element.children()[2]);
718721
}
719722

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

775778
if(nextSplitbar !== null) {
776779
nextSplitbarBeforeButton = angular.element(nextSplitbar.element.children()[0]);
777-
nextSplitbarAfterButton = angular.element(nextSplitbar.element.children()[1]);
780+
nextSplitbarAfterButton = angular.element(nextSplitbar.element.children()[2]);
778781
}
779782

780783
if(ctrl.isUsingColumnFlow) {
@@ -947,8 +950,9 @@ angular.module('ui.layout', [])
947950
var children = parent.children();
948951
var index = ctrl.indexOfElement(element);
949952
var splitbar = angular.element('<div ui-splitbar>' +
950-
'<a><span class="ui-splitbar-icon"></span></a>' +
951-
'<a><span class="ui-splitbar-icon"></span></a>' +
953+
'<a><span class="ui-splitbar-icon ui-splitbar-toggle"></span></a>' +
954+
'<a class="ui-splitbar-handle-container"><span class="ui-splitbar-icon ui-splitbar-handle"></span></a>' +
955+
'<a><span class="ui-splitbar-icon ui-splitbar-toggle"></span></a>' +
952956
'</div>');
953957
if(0 < index && !ctrl.hasSplitbarBefore(scope.container)) {
954958
angular.element(children[index-1]).after(splitbar);

test/layout-scenar.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ function splitMoveTests(description, startEvent, moveEvent, endEvent) {
141141

142142
beforeEach(function() {
143143
toggleBeforeButton = $splitbar.children()[0];
144-
toggleAfterButton = $splitbar.children()[1];
144+
toggleAfterButton = $splitbar.children()[2];
145145
});
146146

147147
it('should exist', function() {

0 commit comments

Comments
 (0)