-
-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
87f0b8d
commit ea15b10
Showing
15 changed files
with
127 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
projects/ngx-scrollbar-demo/src/app/example2/example2.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { ComponentFixture, ComponentFixtureAutoDetect, TestBed } from '@angular/core/testing'; | ||
import { By } from '@angular/platform-browser'; | ||
import { firstValueFrom } from 'rxjs'; | ||
import { NgScrollbar } from 'ngx-scrollbar'; | ||
import { setDimensions } from './common-test.'; | ||
|
||
describe('Hover effect', () => { | ||
let component: NgScrollbar; | ||
let fixture: ComponentFixture<NgScrollbar>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [NgScrollbar], | ||
providers: [ | ||
{ provide: ComponentFixtureAutoDetect, useValue: true } | ||
] | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(NgScrollbar); | ||
component = fixture.componentInstance; | ||
component.nativeElement.style.setProperty('--scrollbar-thickness', '5'); | ||
component.nativeElement.style.setProperty('--scrollbar-hover-thickness', '10'); | ||
component.nativeElement.style.setProperty('--scrollbar-offset', '4'); | ||
}); | ||
|
||
it('Should activate hover effect only when mouse is over the scrollbar in case [hoverOffset]="false"', async () => { | ||
setDimensions(component, { cmpHeight: 200, cmpWidth: 200, contentHeight: 400, contentWidth: 400 }); | ||
fixture.componentRef.setInput('hoverOffset', false); | ||
component.ngOnInit(); | ||
component.ngAfterViewInit(); | ||
await firstValueFrom(component.afterInit); | ||
|
||
const stickyYElement: Element = fixture.debugElement.query(By.css('scrollbar-y .ng-scrollbar-sticky')).nativeElement; | ||
const stickyXElement: Element = fixture.debugElement.query(By.css('scrollbar-x .ng-scrollbar-sticky')).nativeElement; | ||
|
||
const trackYElement: Element = fixture.debugElement.query(By.css('scrollbar-y .ng-scrollbar-track-wrapper')).nativeElement; | ||
const trackXElement: Element = fixture.debugElement.query(By.css('scrollbar-x .ng-scrollbar-track-wrapper')).nativeElement; | ||
|
||
expect(stickyYElement.classList).not.toContain('ng-scrollbar-hover'); | ||
expect(stickyXElement.classList).not.toContain('ng-scrollbar-hover'); | ||
expect(trackYElement.classList).toContain('ng-scrollbar-hover'); | ||
expect(trackXElement.classList).toContain('ng-scrollbar-hover'); | ||
}); | ||
|
||
it('Should activate hover effect when mouse is over the offset area in case [hoverOffset]="true"', async () => { | ||
setDimensions(component, { cmpHeight: 200, cmpWidth: 200, contentHeight: 400, contentWidth: 400 }); | ||
fixture.componentRef.setInput('hoverOffset', true); | ||
component.ngOnInit(); | ||
component.ngAfterViewInit(); | ||
await firstValueFrom(component.afterInit); | ||
|
||
const stickyYElement: Element = fixture.debugElement.query(By.css('scrollbar-y .ng-scrollbar-sticky')).nativeElement; | ||
const stickyXElement: Element = fixture.debugElement.query(By.css('scrollbar-x .ng-scrollbar-sticky')).nativeElement; | ||
|
||
const trackYElement: Element = fixture.debugElement.query(By.css('scrollbar-y .ng-scrollbar-track-wrapper')).nativeElement; | ||
const trackXElement: Element = fixture.debugElement.query(By.css('scrollbar-x .ng-scrollbar-track-wrapper')).nativeElement; | ||
|
||
expect(stickyYElement.classList).toContain('ng-scrollbar-hover'); | ||
expect(stickyXElement.classList).toContain('ng-scrollbar-hover'); | ||
expect(trackYElement.classList).not.toContain('ng-scrollbar-hover'); | ||
expect(trackXElement.classList).not.toContain('ng-scrollbar-hover'); | ||
}); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ea15b10
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 Published on https://ngx-scrollbar.netlify.app as production
🚀 Deployed on https://668f4c7ab1c07cbda31e9bae--ngx-scrollbar.netlify.app