Skip to content

Commit

Permalink
Add a way to prevent scroll in the samples browser (#573)
Browse files Browse the repository at this point in the history
Co-authored-by: HUSSAR-mtrela (Martin Trela) <HUSSAR-mtrela@users.noreply.github.com>
  • Loading branch information
mddragnev and HUSSAR-mtrela authored Oct 26, 2023
1 parent 2e3b34d commit e075e23
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions browser/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,17 @@ export class Router {
private displaySample(sample: any) {
let tagName = sample.htmlTagName;
this._targetEle.innerHTML = `<${tagName} class="sample-content"></${tagName}>`;
this._targetEle.addEventListener('wheel', this.preventDocumentScroll, { passive: false });
}

private public_url = "";

public async navigateToRoute(route: string) {
let navBarIsHidden: boolean = true;

// clear event listener before routing to a new sample
this._targetEle.removeEventListener('wheel', this.preventDocumentScroll);

if (route.indexOf("/webcomponents-demos") === 0) {
this.public_url = "/webcomponents-demos";
route = route.substring("/webcomponents-demos".length);
Expand Down Expand Up @@ -162,4 +166,10 @@ export class Router {
// }
}

private preventDocumentScroll(event:any) {
if (event.target.outerHTML.toLowerCase().includes('igx')) {
event.preventDefault();
}
}

}

0 comments on commit e075e23

Please sign in to comment.