diff --git a/README.md b/README.md index fbcbe92..6bdbad4 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,19 @@ angular.module("app").controller("MyCtrl", function () { **Don't forget to specify an id (or an attribute 'scroll-name') for your scroll pane, otherwise it won't be working** +### Always scroll to top + +If need just specify atribute scroll-always-top. For example, good thing for custom autocomplete list. + +``` + +
+
+ {{item}} +
+
+``` + ### Reinitialize the pane If you want to reinitialize the pane, you can broadcast `reinit-pane` with the ID of the DOM Element. diff --git a/src/jscrollpane.coffee b/src/jscrollpane.coffee index cc6d53f..100a43a 100644 --- a/src/jscrollpane.coffee +++ b/src/jscrollpane.coffee @@ -20,6 +20,12 @@ angular $timeout(fn, $scope.$eval($attrs.scrollTimeout)) else $timeout(fn, 0) + $scope.$watch (-> + $attrs.scrollAlwaysTop + ), (newVal, oldVal) -> + if newVal and $scope.pane + $scope.pane.scrollToY 0 + return $scope.$on("reinit-pane", (event, id) -> if id is $attrs.id and $scope.pane console.log("Reinit pane #{id}")