Skip to content

Commit 1483eb8

Browse files
Martin DragnevMartin Dragnev
Martin Dragnev
authored and
Martin Dragnev
committed
feat(IgxSplitter): Adding expand/collapse functionality #6639
1 parent c82d65f commit 1483eb8

File tree

5 files changed

+78
-9
lines changed

5 files changed

+78
-9
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<div class="igx-splitter__bar" [style.flex-direction]="direction" igxDrag [ghost]="false"
22
(dragStart)='onDragStart($event)'
33
(dragMove)="onDragMove($event)">
4-
<div class="igx-splitter-bar-expander">
5-
<igx-icon fontSet="material">{{collapsePrevIcon}}</igx-icon>
6-
</div>
4+
<div class="igx-splitter-bar-expander" (click)='onCollapsing($event)'>
5+
<igx-icon fontSet="material" [hidden]='prevButtonHidden'>{{collapsePrevIcon}}</igx-icon>
6+
</div>
77
<div class="igx-splitter__bar-handle" [style.cursor]='cursor'
88
[class.igx-splitter__handle-vertical]='type === 0'
99
[class.igx-splitter__handle-horizontal]='type === 1'
1010
igxDragHandle
1111
></div>
12-
<div class="igx-splitter-bar-expander">
13-
<igx-icon fontSet="material">{{collapseNextIcon}}</igx-icon>
12+
<div class="igx-splitter-bar-expander" (click)='onCollapsing($event)' >
13+
<igx-icon fontSet="material" [hidden]='nextButtonHidden' >{{collapseNextIcon}}</igx-icon>
1414
</div>
15-
</div>
15+
</div>

Diff for: projects/igniteui-angular/src/lib/splitter/splitter-bar/splitter-bar.component.ts

+35
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ export class IgxSplitBarComponent {
4949
@Output()
5050
public moving = new EventEmitter<number>();
5151

52+
/**
53+
* An event that is emitted when collapsing the pane
54+
*/
55+
@Output()
56+
public collapse = new EventEmitter<IgxSplitterPaneComponent>();
57+
5258
/**
5359
* Gets the cursor associated with the current `SplitBarComponent`.
5460
* @readonly
@@ -92,6 +98,15 @@ export class IgxSplitBarComponent {
9298
*/
9399
private startPoint!: number;
94100

101+
get prevButtonHidden() {
102+
const isPaneHidden = this.pane.hidden;
103+
return isPaneHidden ? true : false;
104+
}
105+
106+
get nextButtonHidden() {
107+
const isSiblingHidden = this.siblings[0].hidden;
108+
return isSiblingHidden ? true : false;
109+
}
95110
public onDragStart(event: IDragStartEventArgs) {
96111
if (this.resizeDisallowed) {
97112
event.cancel = true;
@@ -122,4 +137,24 @@ export class IgxSplitBarComponent {
122137
return !!relatedTabs.find(x => x.resizable === false);
123138
}
124139

140+
public onCollapsing(event: any) {
141+
const arrowElement = event.srcElement;
142+
const direction = arrowElement.innerText === 'arrow_left' || arrowElement.innerText === 'arrow_drop_up' ? 0 : 1;
143+
let _pane = null;
144+
const sibling = this.siblings[0];
145+
if (!direction) {
146+
if (!this.pane.hidden || !sibling.hidden) {
147+
if (sibling.hidden) {
148+
_pane = sibling;
149+
} else {
150+
if (!this.pane.hidden) {
151+
_pane = this.pane;
152+
}
153+
}
154+
}
155+
} else {
156+
_pane = !this.pane.hidden ? sibling : this.pane;
157+
}
158+
this.collapse.emit(_pane);
159+
}
125160
}

Diff for: projects/igniteui-angular/src/lib/splitter/splitter-pane/splitter-pane.component.ts

+22-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export class IgxSplitterPaneComponent {
7575
public minHeight = 0;
7676

7777
/**
78-
* Sets/gets the `maxHeight` and `maxWidth` propertis of the current `SplitPaneComponent`.
78+
* Sets/gets the `maxHeight` and `maxWidth` propertis of the current `IgxSplitterPaneComponent`.
7979
*/
8080
@HostBinding('style.max-height')
8181
@HostBinding('style.max-width')
@@ -93,5 +93,26 @@ export class IgxSplitterPaneComponent {
9393
return `${grow} ${shrink} ${this.size}`;
9494
}
9595

96+
/**
97+
* Sets/gets the 'display' property of the current `IgxSplitterPaneComponent`
98+
*/
99+
@HostBinding('style.display')
100+
public display = 'flex';
101+
102+
private _hidden = false;
103+
104+
/**
105+
* Sets/gets whether current `IgxSplitterPanecomponent` is hidden
106+
*/
107+
@Input()
108+
public set hidden(value) {
109+
this._hidden = value;
110+
this.display = this._hidden ? 'none' : 'flex' ;
111+
}
112+
113+
public get hidden() {
114+
return this._hidden;
115+
}
116+
96117
constructor(private el: ElementRef) { }
97118
}

Diff for: projects/igniteui-angular/src/lib/splitter/splitter.component.html

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
[pane]="pane"
66
[siblings]='getSiblings(pane)'
77
(moveStart)="onMoveStart($event)"
8-
(moving)="onMoving($event)">
8+
(moving)="onMoving($event)"
9+
(collapse)="onCollapsing($event)">
910
</igx-splitter-bar>
10-
</ng-container>
11+
</ng-container>

Diff for: projects/igniteui-angular/src/lib/splitter/splitter.component.ts

+12
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,18 @@ export class IgxSplitterComponent implements AfterContentInit {
151151
this.sibling.size = siblingSize + 'px';
152152
}
153153

154+
/**
155+
* This method performs the collapsing of the pane
156+
* @param pane
157+
*/
158+
public onCollapsing(pane: IgxSplitterPaneComponent) {
159+
if (!pane) {
160+
return;
161+
}
162+
this.pane = pane;
163+
this.pane.hidden = !this.pane.hidden;
164+
}
165+
154166
/**
155167
* This method takes care for assigning an `order` property on each `IgxSplitterPaneComponent`.
156168
* @private

0 commit comments

Comments
 (0)