-
-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
scrollViewport
directive removes custom CSS classes applied on the viewport element
#505
Comments
Following line causes the issue:
It should prepend existing CSS classes instead of just replacing them. |
I can use |
…he viewport element, closes #505
…he viewport element, closes #505
…he viewport element, closes #505
@MurhafSousli you fix did not work. For some reason Here is some debugging I did. console.log('class name:', this.nativeElement.className);
this.nativeElement.className += `ng-native-scrollbar-hider ng-scroll-viewport ${customClassName}`;
// Check if the custom viewport has only one child and set it as the content wrapper
if (this.nativeElement.firstElementChild) {
this.contentWrapperElement = this.nativeElement.firstElementChild;
this.contentWrapperElement.classList.add('ng-scroll-content');
}
console.log('new class name:', this.nativeElement.className); Output:
If I slightly modify the code: console.log('class name:', this.nativeElement.className);
this.nativeElement.className = `${this.nativeElement.className} ng-native-scrollbar-hider ng-scroll-viewport ${customClassName}`;
// Check if the custom viewport has only one child and set it as the content wrapper
if (this.nativeElement.firstElementChild) {
this.contentWrapperElement = this.nativeElement.firstElementChild;
this.contentWrapperElement.classList.add('ng-scroll-content');
}
console.log('new class name:', this.nativeElement.className); I get correct result:
|
Ok, found out what's the issue. You are missing a space. this.nativeElement.className += `ng-native-scrollbar-hider ng-scroll-viewport ${customClassName}`; but this works: // space before ng-native-scrollbar-hider
this.nativeElement.className += ` ng-native-scrollbar-hider ng-scroll-viewport ${customClassName}`; |
…he viewport element, closes #505
Reproduction
Steps to reproduce:
scrollViewport
directive to your owndiv
Expected Behavior
The class "foo-bar" is retained on the element.
Actual Behavior
scrollViewport
directive overrides all CSS classes andfoo-bar
class is removed.Environment
The text was updated successfully, but these errors were encountered: