-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(module): non-target offset inside nested container (#80)
As pointed out, the offset for nested elements was incorrectly calculated. This PR fixes the calculations.
- Loading branch information
Nicky Lenaers
authored
May 10, 2018
1 parent
489117d
commit 292e479
Showing
12 changed files
with
3,610 additions
and
4,264 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
Large diffs are not rendered by default.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
src/app/+container-offset/container-offset-routing.module.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,26 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { RouterModule, Routes } from '@angular/router'; | ||
|
||
import { ContainerOffsetComponent } from './container-offset.component'; | ||
|
||
const routes: Routes = [ | ||
{ | ||
path: '', | ||
component: ContainerOffsetComponent | ||
}, | ||
{ | ||
path: '**', | ||
redirectTo: '', | ||
pathMatch: 'full' | ||
} | ||
]; | ||
|
||
@NgModule({ | ||
imports: [ | ||
RouterModule.forChild(routes) | ||
], | ||
exports: [ | ||
RouterModule | ||
] | ||
}) | ||
export class ContainerOffsetRoutingModule { } |
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,22 @@ | ||
<h1>Hello {{name}}!</h1> | ||
<p #dialogContentForScroll class="scrollContent"> | ||
<span>Lorem ipsum dolor sit amet<br/></span> | ||
<span>Lorem ipsum dolor sit amet<br/></span> | ||
<span>Lorem ipsum dolor sit amet<br/></span> | ||
<span>Lorem ipsum dolor sit amet<br/></span> | ||
<span>Lorem ipsum dolor sit amet<br/></span> | ||
<span>Lorem ipsum dolor sit amet<br/></span> | ||
<span>Lorem ipsum dolor sit amet<br/></span> | ||
<span>Lorem ipsum dolor sit amet<br/></span> | ||
<span>Lorem ipsum dolor sit amet<br/></span> | ||
<span>Lorem ipsum dolor sit amet<br/></span> | ||
<span>Lorem ipsum dolor sit amet<br/></span> | ||
<span>Lorem ipsum dolor sit amet<br/></span> | ||
<span>Lorem ipsum dolor sit amet<br/></span> | ||
<span>Lorem ipsum dolor sit amet<br/></span> | ||
<span>Lorem ipsum dolor sit amet<br/></span> | ||
<span>Lorem ipsum dolor sit amet<br/></span> | ||
<span>Lorem ipsum dolor sit amet<br/></span> | ||
<span id="target">Target Node</span> | ||
</p> | ||
<div class="space">This is just some space div</div> |
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,17 @@ | ||
:host { | ||
display: block; | ||
} | ||
|
||
.scrollContent { | ||
height: 200px; | ||
overflow-y: scroll; | ||
} | ||
|
||
#target { | ||
display: block; | ||
height: 500px; | ||
} | ||
|
||
.space { | ||
height: 2000px; | ||
} |
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,35 @@ | ||
import { Component, ElementRef, ViewChild, AfterViewInit } from '@angular/core'; | ||
|
||
import { ScrollToService } from '../modules/scroll-to/scroll-to.service'; | ||
import { ScrollToConfigOptions } from '../modules/scroll-to/models/scroll-to-config.model'; | ||
|
||
@Component({ | ||
selector: 'ngx-container-offset', | ||
templateUrl: './container-offset.component.html', | ||
styleUrls: ['./container-offset.component.scss'] | ||
}) | ||
export class ContainerOffsetComponent implements AfterViewInit { | ||
|
||
@ViewChild('dialogContentForScroll') dialogContent: ElementRef; | ||
scrollPosition: number; | ||
name = 'Angular 5'; | ||
|
||
constructor(private readonly scrollToService: ScrollToService) { | ||
this.scrollPosition = 107; | ||
} | ||
|
||
ngAfterViewInit(): void { | ||
|
||
const dialogElement = this.dialogContent.nativeElement as HTMLElement; | ||
|
||
dialogElement.onscroll = () => { | ||
this.scrollPosition = dialogElement.scrollTop; | ||
}; | ||
|
||
this.scrollToService.scrollTo({ | ||
offset: this.scrollPosition, | ||
container: dialogElement | ||
} as ScrollToConfigOptions); | ||
|
||
} | ||
} |
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,22 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
|
||
import { | ||
ContainerOffsetRoutingModule | ||
} from './container-offset-routing.module'; | ||
import { | ||
ContainerOffsetComponent | ||
} from './container-offset.component'; | ||
import { ScrollToModule } from '../modules/scroll-to/scroll-to.module'; | ||
|
||
@NgModule({ | ||
imports: [ | ||
CommonModule, | ||
ContainerOffsetRoutingModule, | ||
ScrollToModule.forRoot() | ||
], | ||
declarations: [ | ||
ContainerOffsetComponent | ||
] | ||
}) | ||
export class ContainerOffsetModule { } |
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