Skip to content

Commit cd8d72d

Browse files
MKirovaMKirova
authored andcommitted
chore(*): Add "resizable" input for pane to allow/disallow resizing.
1 parent 23dd2d0 commit cd8d72d

File tree

5 files changed

+42
-0
lines changed

5 files changed

+42
-0
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ export class IgxSplitBarComponent {
2929
@Input()
3030
public pane!: IgxSplitterPaneComponent;
3131

32+
/**
33+
* Sets/Gets the `SplitPaneComponent` sibling components associated with the current `SplitBarComponent`.
34+
*/
35+
@Input()
36+
public siblings!: Array<IgxSplitterPaneComponent>;
37+
3238
/**
3339
* An event that is emitted whenever we start dragging the current `SplitBarComponent`.
3440
* @memberof SplitBarComponent
@@ -87,6 +93,10 @@ export class IgxSplitBarComponent {
8793
private startPoint!: number;
8894

8995
public onDragStart(event: IDragStartEventArgs) {
96+
if (this.resizeDisallowed) {
97+
event.cancel = true;
98+
return;
99+
}
90100
this.startPoint = this.type === SplitterType.Horizontal ? event.startX : event.startY;
91101
this.moveStart.emit(this.pane);
92102
}
@@ -107,4 +117,9 @@ export class IgxSplitBarComponent {
107117
}
108118
}
109119

120+
protected get resizeDisallowed() {
121+
const relatedTabs = [this.pane, ... this.siblings];
122+
return !!relatedTabs.find(x => x.resizable === false);
123+
}
124+
110125
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ export class IgxSplitterPaneComponent {
3838
@Input()
3939
public maxSize!: string;
4040

41+
/**
42+
* Sets/Gets whether pane is resizable.
43+
*/
44+
@Input()
45+
public resizable = true;
46+
47+
4148
/**
4249
* Sets/gets the `order` property of the current `IgxSplitterPaneComponent`.
4350
*/

projects/igniteui-angular/src/lib/splitter/splitter.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<igx-splitter-bar *ngIf="!last" [style.order]="pane.order + 1"
44
[type]="type"
55
[pane]="pane"
6+
[siblings]='getSiblings(pane)'
67
(moveStart)="onMoveStart($event)"
78
(moving)="onMoving($event)">
89
</igx-splitter-bar>

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,15 @@ describe('IgxSplitter', () => {
123123
expect(pane2.size).toBe('100px');
124124
});
125125

126+
it('should not allow drag resize if resizable is set to false.', () => {
127+
const pane1 = splitter.panes.toArray()[0];
128+
pane1.resizable = false;
129+
const splitterBarComponent = fixture.debugElement.query(By.css(SPLITTERBAR_CLASS)).context;
130+
const args = {cancel: false};
131+
splitterBarComponent.onDragStart(args);
132+
expect(args.cancel).toBeTruthy();
133+
});
134+
126135
});
127136

128137
@Component({

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,4 +163,14 @@ export class IgxSplitterComponent implements AfterContentInit {
163163
k += 2;
164164
});
165165
}
166+
167+
public getSiblings(pane: IgxSplitterPaneComponent): Array<IgxSplitterPaneComponent> {
168+
const panes = this.panes.toArray();
169+
const index = panes.indexOf(pane);
170+
const siblings = [panes[index + 1]];
171+
if (index > 0) {
172+
siblings.push(panes[index - 1]);
173+
}
174+
return siblings;
175+
}
166176
}

0 commit comments

Comments
 (0)