Skip to content

Commit 6a417c6

Browse files
committed
feat(igx-vhelper): create and use css var for scrollbar size
1 parent e4a53bd commit 6a417c6

File tree

4 files changed

+17
-9
lines changed

4 files changed

+17
-9
lines changed

projects/igniteui-angular/src/lib/core/styles/components/_common/_igx-vhelper.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
position: absolute;
1313
top: 0;
1414
inset-inline-end: 0;
15+
width: var(--igx-vhelper--scrollbar-size);
1516
}
1617

1718
%vhelper--horizontal {

projects/igniteui-angular/src/lib/core/styles/components/drop-down/_drop-down-theme.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,10 @@
242242
overflow-x: hidden;
243243
-webkit-overflow-scrolling: touch;
244244
position: relative;
245+
246+
igx-display-container {
247+
padding-inline-end: var(--igx-vhelper--scrollbar-size, 0);
248+
}
245249
}
246250

247251
%igx-drop-down__content {

projects/igniteui-angular/src/lib/core/styles/themes/generators/_base.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@
9595
--ig-spacing-block-large: 1;
9696
}
9797

98+
#{$scope} {
99+
--igx-vhelper-scrollbar-size: 1rem;
100+
}
101+
98102
@if not(list.index($exclude, 'palette')) {
99103
@include palette($palette);
100104
}

projects/igniteui-angular/src/lib/directives/for-of/virtual.helper.component.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Component, ElementRef, HostBinding, Input, ViewChild, ViewContainerRef,
2-
ChangeDetectorRef, OnDestroy, OnInit, Inject, NgZone } from '@angular/core';
2+
ChangeDetectorRef, OnDestroy, Inject, NgZone } from '@angular/core';
33
import { VirtualHelperBaseDirective } from './base.helper.component';
44
import { DOCUMENT } from '@angular/common';
55
import { PlatformUtil } from '../../core/utils';
@@ -9,28 +9,27 @@ import { PlatformUtil } from '../../core/utils';
99
template: '<div #container class="igx-vhelper__placeholder-content" [style.height.px]="size"></div>',
1010
standalone: true
1111
})
12-
export class VirtualHelperComponent extends VirtualHelperBaseDirective implements OnInit, OnDestroy {
12+
export class VirtualHelperComponent extends VirtualHelperBaseDirective implements OnDestroy {
1313
@HostBinding('scrollTop')
1414
public scrollTop;
1515

16-
@HostBinding('style.width.px')
17-
public scrollWidth;
16+
@HostBinding('style.--igx-vhelper--scrollbar-size')
17+
public get scrollbarSize(): string {
18+
const value = `${this.scrollNativeSize}px`;
19+
this.document.documentElement.style.setProperty('--igx-vhelper--scrollbar-size', value);
20+
return value;
21+
}
1822

1923
@ViewChild('container', { read: ViewContainerRef, static: true }) public _vcr;
2024
@Input() public itemsLength: number;
2125

22-
2326
@HostBinding('class')
2427
public cssClasses = 'igx-vhelper--vertical';
2528

2629
constructor(elementRef: ElementRef, cdr: ChangeDetectorRef, zone: NgZone, @Inject(DOCUMENT) document, platformUtil: PlatformUtil) {
2730
super(elementRef, cdr, zone, document, platformUtil);
2831
}
2932

30-
public ngOnInit() {
31-
this.scrollWidth = this.scrollNativeSize;
32-
}
33-
3433
protected override restoreScroll() {
3534
this.nativeElement.scrollTop = this.scrollAmount;
3635
}

0 commit comments

Comments
 (0)