• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

IgniteUI / igniteui-angular / 18742005382

23 Oct 2025 08:15AM UTC coverage: 91.663% (+0.009%) from 91.654%
18742005382

push

github

web-flow
feat(carousel): update carousel theme to match webcomponents (#16284)

Co-authored-by: Silvia Ivanova <59446295+SisIvanova@users.noreply.github.com>
Co-authored-by: Konstantin Dinev <kdinev@infragistics.com>
Co-authored-by: Simeon Simeonoff <sim.simeonoff@gmail.com>

13851 of 16239 branches covered (85.29%)

27840 of 30372 relevant lines covered (91.66%)

34810.11 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.06
/projects/igniteui-angular/src/lib/splitter/splitter.component.ts
1
import { AfterContentInit, Component, ContentChildren, ElementRef, EventEmitter, HostBinding, HostListener, Inject, Input, NgZone, Output, QueryList, booleanAttribute, forwardRef, DOCUMENT } from '@angular/core';
2
import { DragDirection, IDragMoveEventArgs, IDragStartEventArgs, IgxDragDirective, IgxDragIgnoreDirective } from '../directives/drag-drop/drag-drop.directive';
3
import { IgxSplitterPaneComponent } from './splitter-pane/splitter-pane.component';
4
import { take } from 'rxjs';
5

6
/**
7
 * An enumeration that defines the `SplitterComponent` panes orientation.
8
 */
9
export enum SplitterType {
3✔
10
    Horizontal,
3✔
11
    Vertical
3✔
12
}
13

14
export declare interface ISplitterBarResizeEventArgs {
15
    pane: IgxSplitterPaneComponent;
16
    sibling: IgxSplitterPaneComponent;
17
}
18

19
/**
20
 * Provides a framework for a simple layout, splitting the view horizontally or vertically
21
 * into multiple smaller resizable and collapsible areas.
22
 *
23
 * @igxModule IgxSplitterModule
24
 *
25
 * @igxParent Layouts
26
 *
27
 * @igxTheme igx-splitter-theme
28
 *
29
 * @igxKeywords splitter panes layout
30
 *
31
 * @igxGroup presentation
32
 *
33
 * @example
34
 * ```html
35
 * <igx-splitter>
36
 *  <igx-splitter-pane>
37
 *      ...
38
 *  </igx-splitter-pane>
39
 *  <igx-splitter-pane>
40
 *      ...
41
 *  </igx-splitter-pane>
42
 * </igx-splitter>
43
 * ```
44
 */
45
@Component({
46
    selector: 'igx-splitter',
47
    templateUrl: './splitter.component.html',
48
    imports: [forwardRef(() => IgxSplitBarComponent)]
119✔
49
})
50
export class IgxSplitterComponent implements AfterContentInit {
3✔
51
    /**
52
     * Gets the list of splitter panes.
53
     *
54
     * @example
55
     * ```typescript
56
     * const panes = this.splitter.panes;
57
     * ```
58
     */
59
    @ContentChildren(IgxSplitterPaneComponent, { read: IgxSplitterPaneComponent })
60
    public panes!: QueryList<IgxSplitterPaneComponent>;
61

62
    /**
63
    * @hidden
64
    * @internal
65
    */
66
    @HostBinding('class.igx-splitter')
67
    public cssClass = 'igx-splitter';
24✔
68

69
    /**
70
     * @hidden @internal
71
     * Gets/Sets the `overflow` property of the current splitter.
72
     */
73
    @HostBinding('style.overflow')
74
    public overflow = 'hidden';
24✔
75

76
    /**
77
     * @hidden @internal
78
     * Sets/Gets the `display` property of the current splitter.
79
     */
80
    @HostBinding('style.display')
81
    public display = 'flex';
24✔
82

83
    /**
84
     * @hidden
85
     * @internal
86
     */
87
    @HostBinding('attr.aria-orientation')
88
    public get orientation() {
89
        return this.type === SplitterType.Horizontal ? 'horizontal' : 'vertical';
172✔
90
    }
91

92
    /**
93
     * Event fired when resizing of panes starts.
94
     *
95
     * @example
96
     * ```html
97
     * <igx-splitter (resizeStart)='resizeStart($event)'>
98
     *  <igx-splitter-pane>...</igx-splitter-pane>
99
     * </igx-splitter>
100
     * ```
101
     */
102
    @Output()
103
    public resizeStart = new EventEmitter<ISplitterBarResizeEventArgs>();
24✔
104

105
    /**
106
     * Event fired when resizing of panes is in progress.
107
     *
108
     * @example
109
     * ```html
110
     * <igx-splitter (resizing)='resizing($event)'>
111
     *  <igx-splitter-pane>...</igx-splitter-pane>
112
     * </igx-splitter>
113
     * ```
114
     */
115
    @Output()
116
    public resizing = new EventEmitter<ISplitterBarResizeEventArgs>();
24✔
117

118

119
    /**
120
     * Event fired when resizing of panes ends.
121
     *
122
     * @example
123
     * ```html
124
     * <igx-splitter (resizeEnd)='resizeEnd($event)'>
125
     *  <igx-splitter-pane>...</igx-splitter-pane>
126
     * </igx-splitter>
127
     * ```
128
     */
129
    @Output()
130
    public resizeEnd = new EventEmitter<ISplitterBarResizeEventArgs>();
24✔
131

132
    private _type: SplitterType = SplitterType.Horizontal;
24✔
133

134
    /**
135
     * @hidden @internal
136
     * A field that holds the initial size of the main `IgxSplitterPaneComponent` in each pair of panes divided by a splitter bar.
137
     */
138
    private initialPaneSize!: number;
139

140
    /**
141
     * @hidden @internal
142
     * A field that holds the initial size of the sibling pane in each pair of panes divided by a gripper.
143
     * @memberof SplitterComponent
144
     */
145
    private initialSiblingSize!: number;
146

147
    /**
148
     * @hidden @internal
149
     * The main pane in each pair of panes divided by a gripper.
150
     */
151
    private pane!: IgxSplitterPaneComponent;
152

153
    /**
154
     * The sibling pane in each pair of panes divided by a splitter bar.
155
     */
156
    private sibling!: IgxSplitterPaneComponent;
157

158
    constructor(@Inject(DOCUMENT) public document, private elementRef: ElementRef, private zone: NgZone) { }
24✔
159
    /**
160
     * Gets/Sets the splitter orientation.
161
     *
162
     * @example
163
     * ```html
164
     * <igx-splitter [type]="type">...</igx-splitter>
165
     * ```
166
     */
167
    @Input()
168
    public get type() {
169
        return this._type;
696✔
170
    }
171
    public set type(value) {
172
        this._type = value;
29✔
173
        this.resetPaneSizes();
29✔
174
        this.panes?.notifyOnChanges();
29✔
175
    }
176

177
    /**
178
     * Sets the visibility of the handle and expanders in the splitter bar.
179
     * False by default
180
     *
181
     * @example
182
     * ```html
183
     * <igx-splitter [nonCollapsible]='true'>
184
     * </igx-splitter>
185
     * ```
186
     */
187
    @Input({ transform: booleanAttribute })
188
    public nonCollapsible = false; // Input to toggle showing/hiding expanders
24✔
189

190
    /**
191
     * @hidden @internal
192
     * Gets the `flex-direction` property of the current `SplitterComponent`.
193
     */
194
    @HostBinding('style.flex-direction')
195
    public get direction(): string {
196
        return this.type === SplitterType.Horizontal ? 'row' : 'column';
172✔
197
    }
198

199
    /** @hidden @internal */
200
    public ngAfterContentInit(): void {
201
        this.zone.onStable.pipe(take(1)).subscribe(() => {
24✔
202
            this.initPanes();
24✔
203
        });
204
        this.panes.changes.subscribe(() => {
24✔
205
            this.initPanes();
9✔
206
        });
207
    }
208

209
    /**
210
     * @hidden @internal
211
     * This method performs  initialization logic when the user starts dragging the splitter bar between each pair of panes.
212
     * @param pane - the main pane associated with the currently dragged bar.
213
     */
214
    public onMoveStart(pane: IgxSplitterPaneComponent) {
215
        const panes = this.panes.toArray();
18✔
216
        this.pane = pane;
18✔
217
        this.sibling = panes[panes.indexOf(this.pane) + 1];
18✔
218

219
        const paneRect = this.pane.element.getBoundingClientRect();
18✔
220
        this.initialPaneSize = this.type === SplitterType.Horizontal ? paneRect.width : paneRect.height;
18✔
221

222
        const siblingRect = this.sibling.element.getBoundingClientRect();
18✔
223
        this.initialSiblingSize = this.type === SplitterType.Horizontal ? siblingRect.width : siblingRect.height;
18✔
224
        const args: ISplitterBarResizeEventArgs = { pane: this.pane, sibling: this.sibling };
18✔
225
        this.resizeStart.emit(args);
18✔
226
    }
227

228
    /**
229
     * @hidden @internal
230
     * This method performs calculations concerning the sizes of each pair of panes when the bar between them is dragged.
231
     * @param delta - The difference along the X (or Y) axis between the initial and the current point when dragging the bar.
232
     */
233
    public onMoving(delta: number) {
234
        const [ paneSize, siblingSize ] = this.calcNewSizes(delta);
18✔
235

236
        this.pane.dragSize = paneSize + 'px';
18✔
237
        this.sibling.dragSize = siblingSize + 'px';
18✔
238

239
        const args: ISplitterBarResizeEventArgs = { pane: this.pane, sibling: this.sibling };
18✔
240
        this.resizing.emit(args);
18✔
241
    }
242

243
    public onMoveEnd(delta: number) {
244
        let [ paneSize, siblingSize ] = this.calcNewSizes(delta);
6✔
245

246
        if (paneSize + siblingSize > this.getTotalSize() && delta < 0) {
6✔
247
            siblingSize = this.getTotalSize() - paneSize;
1✔
248
        } else if (paneSize + siblingSize > this.getTotalSize() && delta > 0) {
5!
249
            paneSize = this.getTotalSize() - siblingSize;
×
250
        }
251

252
        if (this.pane.isPercentageSize) {
6✔
253
            // handle % resizes
254
            const totalSize = this.getTotalSize();
5✔
255
            const percentPaneSize = (paneSize / totalSize) * 100;
5✔
256
            this.pane.size = percentPaneSize + '%';
5✔
257
        } else {
258
            // px resize
259
            this.pane.size = paneSize + 'px';
1✔
260
        }
261

262
        if (this.sibling.isPercentageSize) {
6✔
263
            // handle % resizes
264
            const totalSize = this.getTotalSize();
4✔
265
            const percentSiblingPaneSize = (siblingSize / totalSize) * 100;
4✔
266
            this.sibling.size = percentSiblingPaneSize + '%';
4✔
267
        } else {
268
            // px resize
269
            this.sibling.size = siblingSize + 'px';
2✔
270
        }
271
        this.pane.dragSize = null;
6✔
272
        this.sibling.dragSize = null;
6✔
273

274
        const args: ISplitterBarResizeEventArgs = { pane: this.pane, sibling: this.sibling };
6✔
275
        this.resizeEnd.emit(args);
6✔
276
    }
277

278
    /** @hidden @internal */
279
    public getPaneSiblingsByOrder(order: number, barIndex: number): Array<IgxSplitterPaneComponent> {
280
        const panes = this.panes.toArray();
220✔
281
        const prevPane = panes[order - barIndex - 1];
220✔
282
        const nextPane = panes[order - barIndex];
220✔
283
        const siblings = [prevPane, nextPane];
220✔
284
        return siblings;
220✔
285
    }
286

287
    private getTotalSize() {
288
        const computed = this.document.defaultView.getComputedStyle(this.elementRef.nativeElement);
22✔
289
        const totalSize = this.type === SplitterType.Horizontal ? computed.getPropertyValue('width') : computed.getPropertyValue('height');
22✔
290
        return parseFloat(totalSize);
22✔
291
    }
292

293

294
    /**
295
     * @hidden @internal
296
     * This method inits panes with properties.
297
     */
298
    private initPanes() {
299
        this.panes.forEach(pane => {
33✔
300
            pane.owner = this;
74✔
301
            if (this.type === SplitterType.Horizontal) {
74✔
302
                pane.minWidth = pane.minSize ?? '0';
55✔
303
                pane.maxWidth = pane.maxSize ?? '100%';
55✔
304
            } else {
305
                pane.minHeight = pane.minSize ?? '0';
19✔
306
                pane.maxHeight = pane.maxSize ?? '100%';
19✔
307
            }
308
        });
309
        this.assignFlexOrder();
33✔
310
        if (this.panes.filter(x => x.collapsed).length > 0) {
74✔
311
            // if any panes are collapsed, reset sizes.
312
            this.resetPaneSizes();
2✔
313
        }
314
    }
315

316
    /**
317
     * @hidden @internal
318
     * This method reset pane sizes.
319
     */
320
    private resetPaneSizes() {
321
        if (this.panes) {
31✔
322
            // if type is changed runtime, should reset sizes.
323
            this.panes.forEach(x => {
9✔
324
                x.size = 'auto'
21✔
325
                x.minWidth = '0';
21✔
326
                x.maxWidth = '100%';
21✔
327
                x.minHeight = '0';
21✔
328
                x.maxHeight = '100%';
21✔
329
            });
330
        }
331
    }
332

333
    /**
334
     * @hidden @internal
335
     * This method assigns the order of each pane.
336
     */
337
    private assignFlexOrder() {
338
        let k = 0;
33✔
339
        this.panes.forEach((pane: IgxSplitterPaneComponent) => {
33✔
340
            pane.order = k;
74✔
341
            k += 2;
74✔
342
        });
343
    }
344

345
    /**
346
     * @hidden @internal
347
     * Calculates new sizes for the panes based on move delta and initial sizes
348
     */
349
    private calcNewSizes(delta: number): [number, number] {
350
        const min = parseInt(this.pane.minSize, 10) || 0;
24✔
351
        const minSibling = parseInt(this.sibling.minSize, 10) || 0;
24✔
352
        const max = parseInt(this.pane.maxSize, 10) || this.initialPaneSize + this.initialSiblingSize - minSibling;
24✔
353
        const maxSibling = parseInt(this.sibling.maxSize, 10) || this.initialPaneSize + this.initialSiblingSize - min;
24✔
354

355
        if (delta < 0) {
24✔
356
            const maxPossibleDelta = Math.min(
16✔
357
                max - this.initialPaneSize,
358
                this.initialSiblingSize - minSibling,
359
            )
360
            delta = Math.min(maxPossibleDelta, Math.abs(delta)) * -1;
16✔
361
        } else {
362
            const maxPossibleDelta = Math.min(
8✔
363
                this.initialPaneSize - min,
364
                maxSibling - this.initialSiblingSize
365
            )
366
            delta = Math.min(maxPossibleDelta, Math.abs(delta));
8✔
367
        }
368
        return [this.initialPaneSize - delta, this.initialSiblingSize + delta];
24✔
369
    }
370
}
371

372
/**
373
 * @hidden @internal
374
 * Represents the draggable bar that visually separates panes and allows for changing their sizes.
375
 */
376
@Component({
377
    selector: 'igx-splitter-bar',
378
    templateUrl: './splitter-bar.component.html',
379
    imports: [IgxDragDirective, IgxDragIgnoreDirective]
380
})
381
export class IgxSplitBarComponent {
3✔
382
    /**
383
     * Set css class to the host element.
384
     */
385
    @HostBinding('class.igx-splitter-bar-host')
386
    public cssClass = 'igx-splitter-bar-host';
31✔
387

388
     /**
389
     * Sets the visibility of the handle and expanders in the splitter bar.
390
     */
391
    @Input({ transform: booleanAttribute })
392
    public nonCollapsible;
393

394
    /**
395
     * Gets/Sets the orientation.
396
     */
397
    @Input()
398
    public type: SplitterType = SplitterType.Horizontal;
31✔
399

400
    /**
401
     * Sets/gets the element order.
402
     */
403
    @HostBinding('style.order')
404
    @Input()
405
    public order!: number;
406

407
    /**
408
     * @hidden
409
     * @internal
410
     */
411
    @HostBinding('attr.tabindex')
412
    public get tabindex() {
413
        return this.resizeDisallowed ? null : 0;
220✔
414
    }
415

416
    /**
417
     * @hidden
418
     * @internal
419
     */
420
    @HostBinding('attr.aria-orientation')
421
    public get orientation() {
422
        return this.type === SplitterType.Horizontal ? 'horizontal' : 'vertical';
220✔
423
    }
424

425
    /**
426
     * @hidden
427
     * @internal
428
     */
429
    public get cursor() {
430
        if (this.resizeDisallowed) {
222✔
431
            return '';
35✔
432
        }
433
        return this.type === SplitterType.Horizontal ? 'col-resize' : 'row-resize';
187✔
434
    }
435

436
    /**
437
     * Sets/gets the `SplitPaneComponent` associated with the current `SplitBarComponent`.
438
     *
439
     * @memberof SplitBarComponent
440
     */
441
    @Input()
442
    public pane!: IgxSplitterPaneComponent;
443

444
    /**
445
     * Sets/Gets the `SplitPaneComponent` sibling components associated with the current `SplitBarComponent`.
446
     */
447
    @Input()
448
    public siblings!: Array<IgxSplitterPaneComponent>;
449

450
    /**
451
     * An event that is emitted whenever we start dragging the current `SplitBarComponent`.
452
     */
453
    @Output()
454
    public moveStart = new EventEmitter<IgxSplitterPaneComponent>();
31✔
455

456
    /**
457
     * An event that is emitted while we are dragging the current `SplitBarComponent`.
458
     */
459
    @Output()
460
    public moving = new EventEmitter<number>();
31✔
461

462
    @Output()
463
    public movingEnd = new EventEmitter<number>();
31✔
464

465
    /**
466
     * A temporary holder for the pointer coordinates.
467
     */
468
    private startPoint!: number;
469

470
    private interactionKeys = new Set('right down left up arrowright arrowdown arrowleft arrowup'.split(' '));
31✔
471

472
    /**
473
     * @hidden @internal
474
     */
475
    public get prevButtonHidden() {
476
        return this.siblings[0]?.collapsed && !this.siblings[1]?.collapsed;
220✔
477
    }
478

479
    /**
480
     * @hidden @internal
481
     */
482
    @HostListener('keydown', ['$event'])
483
    public keyEvent(event: KeyboardEvent) {
484
        const key = event.key.toLowerCase();
17✔
485
        const ctrl = event.ctrlKey;
17✔
486
        event.stopPropagation();
17✔
487
        if (this.interactionKeys.has(key)) {
17✔
488
            event.preventDefault();
17✔
489
        }
490
        switch (key) {
17!
491
            case 'arrowup':
492
            case 'up':
493
                if (this.type === SplitterType.Vertical) {
3✔
494
                    if (ctrl) {
3✔
495
                        this.onCollapsing(false);
2✔
496
                        break;
2✔
497
                    }
498
                    if (!this.resizeDisallowed) {
1✔
499
                        event.preventDefault();
1✔
500
                        this.moveStart.emit(this.pane);
1✔
501
                        this.moving.emit(10);
1✔
502
                    }
503
                }
504
                break;
1✔
505
            case 'arrowdown':
506
            case 'down':
507
                if (this.type === SplitterType.Vertical) {
5✔
508
                    if (ctrl) {
5✔
509
                        this.onCollapsing(true);
2✔
510
                        break;
2✔
511
                    }
512
                    if (!this.resizeDisallowed) {
3✔
513
                        event.preventDefault();
2✔
514
                        this.moveStart.emit(this.pane);
2✔
515
                        this.moving.emit(-10);
2✔
516
                    }
517
                }
518
                break;
3✔
519
            case 'arrowleft':
520
            case 'left':
521
                if (this.type === SplitterType.Horizontal) {
3✔
522
                    if (ctrl) {
3✔
523
                        this.onCollapsing(false);
2✔
524
                        break;
2✔
525
                    }
526
                    if (!this.resizeDisallowed) {
1✔
527
                        event.preventDefault();
1✔
528
                        this.moveStart.emit(this.pane);
1✔
529
                        this.moving.emit(10);
1✔
530
                    }
531
                }
532
                break;
1✔
533
            case 'arrowright':
534
            case 'right':
535
                if (this.type === SplitterType.Horizontal) {
6✔
536
                    if (ctrl) {
6✔
537
                        this.onCollapsing(true);
2✔
538
                        break;
2✔
539
                    }
540
                    if (!this.resizeDisallowed) {
4✔
541
                        event.preventDefault();
2✔
542
                        this.moveStart.emit(this.pane);
2✔
543
                        this.moving.emit(-10);
2✔
544
                    }
545
                }
546
                break;
4✔
547
            default:
548
                break;
×
549
        }
550
    }
551

552
    /**
553
     * @hidden @internal
554
     */
555
    public get dragDir() {
556
        return this.type === SplitterType.Horizontal ? DragDirection.VERTICAL : DragDirection.HORIZONTAL;
220✔
557
    }
558

559
    /**
560
     * @hidden @internal
561
     */
562
    public get nextButtonHidden() {
563
        return this.siblings[1]?.collapsed && !this.siblings[0]?.collapsed;
220✔
564
    }
565

566
    /**
567
     * @hidden @internal
568
     */
569
    public onDragStart(event: IDragStartEventArgs) {
570
        if (this.resizeDisallowed) {
1✔
571
            event.cancel = true;
1✔
572
            return;
1✔
573
        }
574
        this.startPoint = this.type === SplitterType.Horizontal ? event.startX : event.startY;
×
575
        this.moveStart.emit(this.pane);
×
576
    }
577

578
    /**
579
     * @hidden @internal
580
     */
581
    public onDragMove(event: IDragMoveEventArgs) {
582
        const isHorizontal = this.type === SplitterType.Horizontal;
×
583
        const curr = isHorizontal ? event.pageX : event.pageY;
×
584
        const delta = this.startPoint - curr;
×
585
        if (delta !== 0) {
×
586
            this.moving.emit(delta);
×
587
            event.cancel = true;
×
588
            event.owner.element.nativeElement.style.transform = '';
×
589
        }
590
    }
591

592
    public onDragEnd(event: any) {
593
        const isHorizontal = this.type === SplitterType.Horizontal;
×
594
        const curr = isHorizontal ? event.pageX : event.pageY;
×
595
        const delta = this.startPoint - curr;
×
596
        if (delta !== 0) {
×
597
            this.movingEnd.emit(delta);
×
598
        }
599
    }
600

601
    protected get resizeDisallowed() {
602
        const relatedTabs = this.siblings;
452✔
603
        return !!relatedTabs.find(x => x?.resizable === false || x?.collapsed === true);
856✔
604
    }
605

606
    /**
607
     * @hidden @internal
608
     */
609
    public onCollapsing(next: boolean) {
610
        const prevSibling = this.siblings[0];
15✔
611
        const nextSibling = this.siblings[1];
15✔
612
        let target;
613
        if (next) {
15✔
614
            // if next is clicked when prev pane is hidden, show prev pane, else hide next pane.
615
            target = prevSibling.collapsed ? prevSibling : nextSibling;
7✔
616
        } else {
617
            // if prev is clicked when next pane is hidden, show next pane, else hide prev pane.
618
            target = nextSibling.collapsed ? nextSibling : prevSibling;
8✔
619
        }
620
        target.toggle();
15✔
621
    }
622
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc