-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: handle scrolling correctly (#168)
Closes #161
- Loading branch information
1 parent
2e85d3d
commit c9fa496
Showing
25 changed files
with
247 additions
and
64 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
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 @@ | ||
export * from './src/public_api'; |
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,19 @@ | ||
{ | ||
"ngPackage": { | ||
"lib": { | ||
"umdModuleIds": { | ||
"@sbb-esta/angular-core": "sbbAngularCore", | ||
"@sbb-esta/angular-core/base": "sbbAngularCoreBase", | ||
"@sbb-esta/angular-core/breakpoints": "sbbAngularCoreBreakpoints", | ||
"@sbb-esta/angular-core/common-behaviors": "sbbAngularCoreCommonBehaviors", | ||
"@sbb-esta/angular-core/datetime": "sbbAngularCoreDatetime", | ||
"@sbb-esta/angular-core/error": "sbbAngularCoreError", | ||
"@sbb-esta/angular-core/forms": "sbbAngularCoreForms", | ||
"@sbb-esta/angular-core/icon-directive": "sbbAngularCoreIconDirective", | ||
"@sbb-esta/angular-core/models": "sbbAngularCoreModels", | ||
"@sbb-esta/angular-icons": "sbbAngularIcons", | ||
"ngx-perfect-scrollbar": "ngxPerfectScrollbar" | ||
} | ||
} | ||
} | ||
} |
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,28 @@ | ||
The `scrolling` module wraps the [ngx-perfect-scrollbar](https://www.npmjs.com/package/ngx-perfect-scrollbar) | ||
package. The wrapper fixes an issue with the [CDK Overlay](https://material.angular.io/cdk/overlay/overview) | ||
integration. | ||
|
||
### Usage | ||
|
||
See the documentation for [ngx-perfect-scrollbar](https://www.npmjs.com/package/ngx-perfect-scrollbar) | ||
on how to use the `perfect-scrollbar`. | ||
|
||
```ts | ||
import { ScrollingModule } from '@sbb-esta/angular-core/scrolling'; | ||
|
||
@NgModule({ | ||
... | ||
imports: [ | ||
... | ||
ScrollingModule, | ||
... | ||
] | ||
}) | ||
export class AppModule {} | ||
``` | ||
|
||
```html | ||
<perfect-scrollbar style="max-width: 600px; max-height: 400px;" [config]="config"> | ||
<div>Scrollable content</div> | ||
</perfect-scrollbar> | ||
``` |
58 changes: 58 additions & 0 deletions
58
projects/sbb-esta/angular-core/scrolling/src/ps-scrollable.directive.spec.ts
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,58 @@ | ||
import { ElementRef } from '@angular/core'; | ||
import { Subject } from 'rxjs'; | ||
|
||
import { PsComponentScrollable, PsDirectiveScrollable } from './ps-scrollable.directive'; | ||
|
||
describe('PsDirectiveScrollable', () => { | ||
const perfectScrollbarMock = { | ||
psScrollY: new Subject(), | ||
psScrollX: new Subject() | ||
}; | ||
const scrollDispatcherMock = { | ||
register(): void {}, | ||
deregister(): void {} | ||
}; | ||
|
||
it('should emit on inner scroll', () => { | ||
const directive = new PsDirectiveScrollable( | ||
perfectScrollbarMock as any, | ||
new ElementRef(null), | ||
scrollDispatcherMock as any, | ||
null, | ||
null | ||
); | ||
let counter = 0; | ||
directive.elementScrolled().subscribe(() => ++counter); | ||
perfectScrollbarMock.psScrollX.next(); | ||
expect(counter).toBe(1); | ||
perfectScrollbarMock.psScrollY.next(); | ||
expect(counter).toBe(2); | ||
}); | ||
}); | ||
|
||
describe('PsComponentScrollable', () => { | ||
const perfectScrollbarMock = { | ||
psScrollY: new Subject(), | ||
psScrollX: new Subject() | ||
}; | ||
const scrollDispatcherMock = { | ||
register(): void {}, | ||
deregister(): void {} | ||
}; | ||
|
||
it('should emit on inner scroll', () => { | ||
const directive = new PsComponentScrollable( | ||
perfectScrollbarMock as any, | ||
new ElementRef(null), | ||
scrollDispatcherMock as any, | ||
null, | ||
null | ||
); | ||
let counter = 0; | ||
directive.elementScrolled().subscribe(() => ++counter); | ||
perfectScrollbarMock.psScrollX.next(); | ||
expect(counter).toBe(1); | ||
perfectScrollbarMock.psScrollY.next(); | ||
expect(counter).toBe(2); | ||
}); | ||
}); |
Oops, something went wrong.