-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1838 from IgniteUI/preventDocumentScroll-m
Add scroll directive for igxGrid, which aim si to prevent document scrolling
- Loading branch information
Showing
243 changed files
with
1,022 additions
and
874 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
331 changes: 166 additions & 165 deletions
331
live-editing/configs/HierarchicalGridConfigGenerator.ts
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
61 changes: 61 additions & 0 deletions
61
projects/app-lob/src/app/directives/prevent-scroll.directive.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,61 @@ | ||
import { AfterViewInit, Directive, Host, Input, NgModule, Optional } from "@angular/core"; | ||
import { IgxGridBaseDirective } from "igniteui-angular"; | ||
|
||
@Directive({ | ||
selector: "[igxPreventDocumentScroll]" | ||
}) | ||
export class IgxPreventDocumentScrollDirective implements AfterViewInit { | ||
private _preventScroll = true; | ||
private gridBody: HTMLElement; | ||
|
||
/** | ||
* A boolean indicating if page scroll should be prevented while mouse wheeling over the grid, | ||
* when grid scroll has reached top or bottom. Defaults to true. | ||
* ```html | ||
* <igx-grid igxPreventDocumentScroll></igx-grid> | ||
* <igx-grid [igxPreventDocumentScroll]="false"></igx-grid> | ||
* ``` | ||
*/ | ||
@Input("igxPreventDocumentScroll") | ||
public set preventScroll(val: boolean) { | ||
if (val === false) { this._preventScroll = false; } | ||
} | ||
|
||
/** | ||
* @hidden | ||
*/ | ||
constructor(@Host() @Optional() private grid: IgxGridBaseDirective) { | ||
this.gridBody = this.getGridBody(); | ||
} | ||
|
||
public ngAfterViewInit() { | ||
if (this._preventScroll) { | ||
this.gridBody.addEventListener("wheel", this.preventDocumentScroll, { passive: false }); | ||
} | ||
} | ||
|
||
public ngOnDestroy() { | ||
this.gridBody.removeEventListener("wheel", this.preventDocumentScroll); | ||
} | ||
|
||
/** | ||
* Prevents scrolling the page, when mouse wheel over the grid body. | ||
*/ | ||
private preventDocumentScroll(event) { | ||
event.preventDefault(); | ||
} | ||
|
||
private getGridBody(): HTMLElement { | ||
return this.grid.nativeElement; | ||
} | ||
} | ||
|
||
/** | ||
* @hidden | ||
*/ | ||
@NgModule({ | ||
declarations: [IgxPreventDocumentScrollDirective], | ||
exports: [IgxPreventDocumentScrollDirective] | ||
}) | ||
|
||
export class IgxPreventDocumentScrollModule { } |
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
2 changes: 1 addition & 1 deletion
2
projects/app-lob/src/app/grid-crm/grid-crm/grid-crm/grid-crm.component.html
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
2 changes: 1 addition & 1 deletion
2
projects/app-lob/src/app/grid-dynamic-chart-data/grid-dynamic-chart-data.component.html
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
Oops, something went wrong.