How to setup and use the yOffset property of $anchorScroll in AngularJS

二次信任 提交于 2019-12-09 08:05:51

问题


I use the $anchorScroll-service in AngularJS. It works fine. But I have a fixed navigation bar at the top and the scrolling location goes always x-pixels to far.

Now in the $anchorScroll documentation there is a property called yOffset. According to the documentation it should fix my problem.

I don't know how to use this yOffset-property however, because this specific part has no example.

How can I use the yOffset-property of the $anchorScroll-service?


回答1:


There is an example that illustrates how to use yOffset at the bottom of the $anchorScroll documentation.

// offset position by 100px down from the top
$anchorScroll.yOffset = 100;

This is the example plunker



来源:https://stackoverflow.com/questions/26543396/how-to-setup-and-use-the-yoffset-property-of-anchorscroll-in-angularjs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!