-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(select): disable layout scrolling (#1012)
Closes #992
- Loading branch information
1 parent
0e0be88
commit 1bd8214
Showing
7 changed files
with
71 additions
and
8 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
39 changes: 35 additions & 4 deletions
39
src/framework/theme/components/cdk/adapter/block-scroll-strategy-adapter.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 |
---|---|---|
@@ -1,11 +1,42 @@ | ||
import { Injectable, Inject } from '@angular/core'; | ||
import { BlockScrollStrategy } from '@angular/cdk/overlay'; | ||
import { Inject, Injectable, NgZone } from '@angular/core'; | ||
import { BlockScrollStrategy, ScrollDispatcher, ScrollStrategyOptions } from '@angular/cdk/overlay'; | ||
|
||
import { NbLayoutScrollService } from '../../../services/scroll.service'; | ||
import { NB_DOCUMENT } from '../../../theme.options'; | ||
import { NbViewportRulerAdapter } from './viewport-ruler-adapter'; | ||
|
||
|
||
/** | ||
* Overrides default block scroll strategy because default strategy blocks scrolling on the body only. | ||
* But Nebular has its own scrollable container - nb-layout. So, we need to block scrolling in it to. | ||
* */ | ||
@Injectable() | ||
export class NbBlockScrollStrategyAdapter extends BlockScrollStrategy { | ||
constructor(ruler: NbViewportRulerAdapter, @Inject(NB_DOCUMENT) document) { | ||
super(ruler, document); | ||
constructor(@Inject(NB_DOCUMENT) document: any, | ||
viewportRuler: NbViewportRulerAdapter, | ||
protected scrollService: NbLayoutScrollService) { | ||
super(viewportRuler, document); | ||
} | ||
|
||
enable() { | ||
super.enable(); | ||
this.scrollService.scrollable(false); | ||
} | ||
|
||
disable() { | ||
super.disable(); | ||
this.scrollService.scrollable(true); | ||
} | ||
} | ||
|
||
export class NbScrollStrategyOptions extends ScrollStrategyOptions { | ||
constructor(protected scrollService: NbLayoutScrollService, | ||
protected scrollDispatcher: ScrollDispatcher, | ||
protected viewportRuler: NbViewportRulerAdapter, | ||
protected ngZone: NgZone, | ||
@Inject(NB_DOCUMENT) protected document) { | ||
super(scrollDispatcher, viewportRuler, ngZone, document); | ||
} | ||
|
||
block = () => new NbBlockScrollStrategyAdapter(this.document, this.viewportRuler, this.scrollService); | ||
} |
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