Skip to content

Commit dcd0932

Browse files
authored
Merge pull request #7126 from IgniteUI/mkirova/splitter-spec-changes
Apply changes as per the spec changes.
2 parents 4000a7c + 10dd7f4 commit dcd0932

File tree

9 files changed

+217
-170
lines changed

9 files changed

+217
-170
lines changed

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

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ import {DragDirection, IDragMoveEventArgs, IDragStartEventArgs} from '../../dire
77
export const SPLITTER_INTERACTION_KEYS = new Set('right down left up arrowright arrowdown arrowleft arrowup'.split(' '));
88

99
/**
10-
* Provides reference to `SplitBarComponent` component.
11-
* Represents the draggable gripper that visually separates panes and allows for changing their sizes.
12-
* @export
13-
* @class SplitBarComponent
10+
* @hidden @internal
11+
* Represents the draggable bar that visually separates panes and allows for changing their sizes.
1412
*/
1513
@Component({
1614
selector: 'igx-splitter-bar',
@@ -24,15 +22,13 @@ export class IgxSplitBarComponent {
2422
public cssClass = 'igx-splitter-bar-host';
2523

2624
/**
27-
* Sets/gets `IgxSplitBarComponent` orientation.
28-
* @type SplitterType
25+
* Gets/Sets the orientation.
2926
*/
3027
@Input()
31-
public type: SplitterType = SplitterType.Vertical;
28+
public type: SplitterType = SplitterType.Horizontal;
3229

3330
/**
34-
* Sets/gets `IgxSplitBarComponent` element order.
35-
* @type SplitterType
31+
* Sets/gets the element order.
3632
*/
3733
@HostBinding('style.order')
3834
@Input()
@@ -43,7 +39,18 @@ export class IgxSplitBarComponent {
4339
* @internal
4440
*/
4541
@HostBinding('attr.tabindex')
46-
public tabindex = 0;
42+
public get tabindex() {
43+
return this.resizeDisallowed ? null : 0;
44+
}
45+
46+
/**
47+
* @hidden
48+
* @internal
49+
*/
50+
@HostBinding('attr.aria-orientation')
51+
public get orientation() {
52+
return this.type === SplitterType.Horizontal ? 'horizontal' : 'vertical';
53+
}
4754

4855
/**
4956
* @hidden
@@ -71,35 +78,26 @@ export class IgxSplitBarComponent {
7178

7279
/**
7380
* An event that is emitted whenever we start dragging the current `SplitBarComponent`.
74-
* @memberof SplitBarComponent
7581
*/
7682
@Output()
7783
public moveStart = new EventEmitter<IgxSplitterPaneComponent>();
7884

7985
/**
8086
* An event that is emitted while we are dragging the current `SplitBarComponent`.
81-
* @memberof SplitBarComponent
8287
*/
8388
@Output()
8489
public moving = new EventEmitter<number>();
8590

86-
/**
87-
* An event that is emitted when collapsing the pane
88-
*/
89-
@Output()
90-
public togglePane = new EventEmitter<IgxSplitterPaneComponent>();
9191
/**
9292
* A temporary holder for the pointer coordinates.
93-
* @private
94-
* @memberof SplitBarComponent
9593
*/
9694
private startPoint!: number;
9795

9896
/**
9997
* @hidden @internal
10098
*/
10199
public get prevButtonHidden() {
102-
return this.siblings[0].hidden && !this.siblings[1].hidden;
100+
return this.siblings[0].collapsed && !this.siblings[1].collapsed;
103101
}
104102

105103
/**
@@ -186,9 +184,12 @@ export class IgxSplitBarComponent {
186184
* @hidden @internal
187185
*/
188186
public get nextButtonHidden() {
189-
return this.siblings[1].hidden && !this.siblings[0].hidden;
187+
return this.siblings[1].collapsed && !this.siblings[0].collapsed;
190188
}
191189

190+
/**
191+
* @hidden @internal
192+
*/
192193
public onDragStart(event: IDragStartEventArgs) {
193194
if (this.resizeDisallowed) {
194195
event.cancel = true;
@@ -198,6 +199,9 @@ export class IgxSplitBarComponent {
198199
this.moveStart.emit(this.pane);
199200
}
200201

202+
/**
203+
* @hidden @internal
204+
*/
201205
public onDragMove(event: IDragMoveEventArgs) {
202206
const isHorizontal = this.type === SplitterType.Horizontal;
203207
const curr = isHorizontal ? event.pageX : event.pageY;
@@ -211,20 +215,23 @@ export class IgxSplitBarComponent {
211215

212216
protected get resizeDisallowed() {
213217
const relatedTabs = this.siblings;
214-
return !!relatedTabs.find(x => x.resizable === false || x.hidden === true);
218+
return !!relatedTabs.find(x => x.resizable === false || x.collapsed === true);
215219
}
216220

221+
/**
222+
* @hidden @internal
223+
*/
217224
public onCollapsing(next: boolean) {
218225
const prevSibling = this.siblings[0];
219226
const nextSibling = this.siblings[1];
220227
let target;
221228
if (next) {
222229
// if next is clicked when prev pane is hidden, show prev pane, else hide next pane.
223-
target = prevSibling.hidden ? prevSibling : nextSibling;
230+
target = prevSibling.collapsed ? prevSibling : nextSibling;
224231
} else {
225232
// if prev is clicked when next pane is hidden, show next pane, else hide prev pane.
226-
target = nextSibling.hidden ? nextSibling : prevSibling;
233+
target = nextSibling.collapsed ? nextSibling : prevSibling;
227234
}
228-
this.togglePane.emit(target);
235+
target.toggle();
229236
}
230237
}
Lines changed: 105 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,38 @@
11
import { Component, HostBinding, Input, ElementRef, Output, EventEmitter } from '@angular/core';
22

33
/**
4-
* Provides reference to `SplitPaneComponent` component.
5-
* Represents individual resizable panes. Users can control the resize behavior via the min and max size properties.
6-
* @export
7-
* @class SplitPaneComponent
4+
* Represents individual resizable/collapsible panes.
5+
* @igxModule IgxSplitterModule
6+
*
7+
* @igxParent IgxSplitterComponent
8+
*
9+
* @igxKeywords pane
10+
*
11+
* @igxGroup presentation
12+
*
13+
* @remarks
14+
* Users can control the resize behavior via the min and max size properties.
815
*/
916
@Component({
1017
selector: 'igx-splitter-pane',
1118
templateUrl: './splitter-pane.component.html'
1219
})
1320
export class IgxSplitterPaneComponent {
1421

15-
public _size = 'auto';
22+
private _size = 'auto';
23+
private _collapsed = false;
24+
25+
/** @hidden @internal */
26+
public owner;
27+
1628
/**
17-
* Sets/gets the size of the current `IgxSplitterPaneComponent`.
29+
* Gets/Sets the size of the current pane.
30+
* * @example
31+
* ```html
32+
* <igx-splitter>
33+
* <igx-splitter-pane [size]='size'>...</igx-splitter-pane>
34+
* </igx-splitter>
35+
* ```
1836
*/
1937
@Input()
2038
get size() {
@@ -24,73 +42,98 @@ export class IgxSplitterPaneComponent {
2442
set size(value) {
2543
this._size = value;
2644
this.el.nativeElement.style.flex = this.flex;
27-
this.sizeChange.emit(value);
2845
}
2946

3047
/**
31-
* @hidden @internal
32-
*/
33-
@Output()
34-
public sizeChange = new EventEmitter<string>();
35-
36-
/**
37-
* Sets/gets the minimum allowable size of the current `IgxSplitterPaneComponent`.
48+
* Gets/Sets the minimum allowed size of the current pane.
49+
* @example
50+
* ```html
51+
* <igx-splitter>
52+
* <igx-splitter-pane [minSize]='minSize'>...</igx-splitter-pane>
53+
* </igx-splitter>
54+
* ```
3855
*/
3956
@Input()
4057
public minSize!: string;
4158

4259
/**
43-
* Sets/gets the maximum allowable size of the current `IgxSplitterPaneComponent`.
60+
* Gets/Set the maximum allowed size of the current pane.
61+
* @example
62+
* ```html
63+
* <igx-splitter>
64+
* <igx-splitter-pane [maxSize]='maxSize'>...</igx-splitter-pane>
65+
* </igx-splitter>
66+
* ```
4467
*/
4568
@Input()
4669
public maxSize!: string;
4770

4871
/**
49-
* Sets/Gets whether pane is resizable.
72+
* Gets/Sets whether pane is resizable.
73+
* @example
74+
* ```html
75+
* <igx-splitter>
76+
* <igx-splitter-pane [resizable]='false'>...</igx-splitter-pane>
77+
* </igx-splitter>
78+
* ```
79+
* @remarks
80+
* If pane is not resizable its related splitter bar cannot be dragged.
5081
*/
5182
@Input()
5283
public resizable = true;
5384

54-
5585
/**
56-
* Sets/gets the `order` property of the current `IgxSplitterPaneComponent`.
86+
* Event fired when collapsed state of pane is changed.
87+
* @example
88+
* ```html
89+
* <igx-splitter>
90+
* <igx-splitter-pane (onToggle)='onPaneToggle($event)'>...</igx-splitter-pane>
91+
* </igx-splitter>
92+
* ```
5793
*/
58-
@Input()
94+
@Output()
95+
public onToggle = new EventEmitter<IgxSplitterPaneComponent>();
96+
97+
98+
/** @hidden @internal */
5999
@HostBinding('style.order')
60100
public order!: number;
61101

62102
/**
103+
*
104+
* @hidden @internal
63105
* Gets the host native element.
64-
* @readonly
65-
* @type *
66106
*/
67107
public get element(): any {
68108
return this.el.nativeElement;
69109
}
70110

71111
/**
72-
* Sets/gets the `overflow` property of the current `IgxSplitterPaneComponent`.
112+
* @hidden @internal
113+
* Gets/Sets the `overflow`.
73114
*/
74115
@HostBinding('style.overflow')
75116
public overflow = 'auto';
76117

77118
/**
78-
* Sets/gets the `minHeight` and `minWidth` propertis of the current `IgxSplitterPaneComponent`.
119+
* @hidden @internal
120+
* Gets/Sets the `minHeight` and `minWidth` properties of the current pane.
79121
*/
80122
@HostBinding('style.min-height')
81123
@HostBinding('style.min-width')
82124
public minHeight = 0;
83125

84126
/**
85-
* Sets/gets the `maxHeight` and `maxWidth` propertis of the current `IgxSplitterPaneComponent`.
127+
* @hidden @internal
128+
* Gets/Sets the `maxHeight` and `maxWidth` properties of the current `IgxSplitterPaneComponent`.
86129
*/
87130
@HostBinding('style.max-height')
88131
@HostBinding('style.max-width')
89132
public maxHeight = '100%';
90133

91134
/**
135+
* @hidden @internal
92136
* Gets the `flex` property of the current `IgxSplitterPaneComponent`.
93-
* @readonly
94137
*/
95138
@HostBinding('style.flex')
96139
public get flex() {
@@ -101,31 +144,56 @@ export class IgxSplitterPaneComponent {
101144
}
102145

103146
/**
104-
* Sets/gets the 'display' property of the current `IgxSplitterPaneComponent`
147+
* @hidden @internal
148+
* Gets/Sets the 'display' property of the current pane.
105149
*/
106150
@HostBinding('style.display')
107151
public display = 'flex';
108152

109-
private _hidden = false;
110-
111153
/**
112-
* Sets/gets whether current `IgxSplitterPanecomponent` is hidden
154+
* Gets/Sets whether current pane is collapsed.
155+
* @example
156+
* ```typescript
157+
* const isCollapsed = pane.collapsed;
158+
* ```
113159
*/
114160
@Input()
115-
public set hidden(value) {
116-
this._hidden = value;
117-
this.display = this._hidden ? 'none' : 'flex' ;
161+
public set collapsed(value) {
162+
this._collapsed = value;
163+
this.display = this._collapsed ? 'none' : 'flex' ;
164+
}
165+
166+
public get collapsed() {
167+
return this._collapsed;
118168
}
119169

120-
public get hidden() {
121-
return this._hidden;
170+
/** @hidden @internal */
171+
private _getSiblings() {
172+
const panes = this.owner.panes.toArray();
173+
const index = panes.indexOf(this);
174+
const siblings = [];
175+
if (index !== 0) {
176+
siblings.push(panes[index - 1]);
177+
}
178+
if (index !== panes.length - 1) {
179+
siblings.push(panes[index + 1]);
180+
}
181+
return siblings;
122182
}
123183

124184
/**
125-
* Event fired when collapsing and changing the hidden state of the current pane
185+
* Toggles the collapsed state of the pane.
186+
* @example
187+
* ```typescript
188+
* pane.toggle();
189+
* ```
126190
*/
127-
@Output()
128-
public onPaneToggle = new EventEmitter<IgxSplitterPaneComponent>();
191+
public toggle() {
192+
// reset sibling sizes when pane collapse state changes.
193+
this._getSiblings().forEach(sibling => sibling.size = 'auto');
194+
this.collapsed = !this.collapsed;
195+
this.onToggle.emit(this);
196+
}
129197

130198
constructor(private el: ElementRef) { }
131199
}
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
<ng-content select="igx-splitter-pane"></ng-content>
22
<ng-container *ngFor="let pane of panes; let last = last; let index= index;">
3-
<igx-splitter-bar *ngIf="!last" [order]='pane.order + 1'
3+
<igx-splitter-bar *ngIf="!last" [order]='pane.order + 1' role='separator'
44
[type]="type"
55
[pane]="pane"
66
[siblings]='getPaneSiblingsByOrder(pane.order + 1, index)'
77
(moveStart)="onMoveStart($event)"
8-
(moving)="onMoving($event)"
9-
(togglePane)="togglePane($event)">
8+
(moving)="onMoving($event)">
109
</igx-splitter-bar>
1110
</ng-container>

0 commit comments

Comments
 (0)