Skip to content

Commit c530919

Browse files
Merge pull request #4 from morow93/master
Add auto scroll to top
2 parents 7d63b61 + 7daeac2 commit c530919

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,19 @@ angular.module("app").controller("MyCtrl", function () {
3939

4040
**Don't forget to specify an id (or an attribute 'scroll-name') for your scroll pane, otherwise it won't be working**
4141

42+
### Always scroll to top
43+
44+
If need just specify atribute scroll-always-top. For example, good thing for custom autocomplete list.
45+
46+
```
47+
<input type="text" ng-model="someText" />
48+
<div scroll-pane scroll-config="paneConfig" id="myScrollPane" scroll-always-top="{{someText}}">
49+
<div ng-repeat="item in items track by $index">
50+
<span>{{item}}</span>
51+
</div>
52+
</div>
53+
```
54+
4255
### Reinitialize the pane
4356

4457
If you want to reinitialize the pane, you can broadcast `reinit-pane` with the ID of the DOM Element.

src/jscrollpane.coffee

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ angular
2020
$timeout(fn, $scope.$eval($attrs.scrollTimeout))
2121
else
2222
$timeout(fn, 0)
23+
$scope.$watch (->
24+
$attrs.scrollAlwaysTop
25+
), (newVal, oldVal) ->
26+
if newVal and $scope.pane
27+
$scope.pane.scrollToY 0
28+
return
2329
$scope.$on("reinit-pane", (event, id) ->
2430
if id is $attrs.id and $scope.pane
2531
console.log("Reinit pane #{id}")

0 commit comments

Comments
 (0)