ScrollTo function in AngularJS

后端 未结 9 1875
梦如初夏
梦如初夏 2020-11-27 11:43

I\'m trying to get a quick nav to work correctly. It\'s floating on the side. When they click on a link, it takes them to that ID on the page. I\'m following this guide fro

9条回答
  •  情歌与酒
    2020-11-27 12:03

    In order to animate to a specific element inside a scroll container (fixed DIV)

    /*
        @param Container(DIV) that needs to be scrolled, ID or Div of the anchor element that should be scrolled to
        Scrolls to a specific element in the div container
    */
    this.scrollTo = function(container, anchor) {
        var element = angular.element(anchor);
        angular.element(container).animate({scrollTop: element.offset().top}, "slow");
    }
    

提交回复
热议问题