[Layout] NbLayoutScrollService code example request
See original GitHub issueIssue type
I’m submitting a … (check one with “x”)
- feature request
Issue description
Current behavior: NbLayoutScrollService documentation is really dry.
Expected behavior: Some code examples would be much appreciated.
Steps to reproduce:
Related code: I attempted to figure out how it work, but for a newbie it’s a bit too much without a guidance. Here is what i thought should work.
ngAfterViewChecked(): void {
function getOffset(el) {
const rect = el.getBoundingClientRect();
return {
left: rect.left + window.scrollX,
top: rect.top + window.scrollY
};
}
try {
const pageElement = document.getElementById(this.fragment);
if (pageElement) {
this.scrollService.scrollTo(getOffset(pageElement).left, getOffset(pageElement).top);
this.fragment = '';
}
} catch (e) { }
}
Angular, Nebular
"@angular/core": "6.0.3"
"@nebular/auth": "^2.0.0-rc.10"
"@nebular/security": "^2.0.0-rc.10"
"@nebular/theme": "^2.0.0-rc.10"
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:5
Top Results From Across the Web
Nebular - LayoutScrollService - GitHub Pages
NbLayoutScrollService. Layout scroll service. Provides information about current scroll position, as well as methods to update position of the scroll.
Read more >Getting started with Nebular for Angular
Open src\app\app.component.html and insert the following code. <nb-layout> < ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @nnixaa , Maybe i’m conceptually wrong here. My understanding is that this service allows for a page scroll similar to scrollIntoView() function. I’m looking for an alternative to this function as its following usage doesn’t work in Safari:
So, i was looking for some example of NbLayoutScrollService usage, just to see how the service should be used. With the code i provided in the original post i get no errors, just no scroll happens.
Hope this makes sense. Let me know if you need more info.
Cheers,
This worked for me: