Skip to content

Commit

Permalink
fix: scroll to element with relative positioned parent (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
izmaylovdev authored and Rafa AS committed Jan 9, 2020
1 parent 35c21a2 commit 4d2c775
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion projects/ngx-scroll-to/src/lib/scroll-to.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ export class ScrollToService {
let to = container ? container.getBoundingClientRect().top : 0;

if (targetNode) {
to = isWindow(listenerTarget) ? targetNode.offsetTop : targetNode.getBoundingClientRect().top;
to = isWindow(listenerTarget) ?
window.scrollY + targetNode.getBoundingClientRect().top :
targetNode.getBoundingClientRect().top;
}

// Create Animation
Expand Down

0 comments on commit 4d2c775

Please sign in to comment.