DEV/JS

[Angular] fragment(/#) 스크롤 포커스 이동하게 하기

zineeworld 2020. 6. 26. 11:49
반응형

단순하게 <div id="target"></div> 원하는 곳에 아이디를 만들고, 링크에 <a href="#target">타겟 이동</a> 하면 되는데 앵귤러에서는 제대로 작동하지 않아서 찾아보니 아래와 같은 방법이 있었다.

 

https://stackoverflow.com/questions/46658522/how-to-smooth-scroll-to-page-anchor-in-angular-4-without-plugins-properly

 

How to smooth scroll to page anchor in angular 4 without plugins properly?

What I want to achieve is a click to and do a smooth scroll to bottom / specified div area which i define with hashtag just like i think it should be like this. here is the live example in the

stackoverflow.com

 

https://developer.mozilla.org/ko/docs/Web/API/Element/scrollIntoView

 

element.scrollIntoView

다른 요소의 레이아웃에 따라 위쪽 또는 아래쪽으로 완전히 스크롤되지 않을 수 있습니다.

developer.mozilla.org

 

반응형