iominh / ng-scrollbars

Angular wrapper of Malihu's jQuery Custom Scrollbar
http://iominh.github.io/ng-scrollbars/
MIT License
202 stars 62 forks source link

How to use $watch to monitor the top of the element which generates by ng-scrollbar #53

Open knonginda opened 7 years ago

knonginda commented 7 years ago

Hi, I am a newbie for Angular, in this case, I use window scroll event to monitor the scrollTop to change the class name, but after using ng-scrollbar, I found I couldn't do it in that way because ng-scrollbar is used to change the top of style to scroll the viewport.

The following example shows my old codes, then how to use $watch to monitor the top of the element which is generated by ng-scrollbar:

          angular.element(window).bind("scroll", function() {
                if (this.pageYOffset >= 54) {
                    $scope.isVisible = false;
                } else {
                    $scope.isVisible = true;
                }
                $scope.$apply();
            });