Skip to content

Commit

Permalink
Merge pull request #4 from morow93/master
Browse files Browse the repository at this point in the history
Add auto scroll to top
  • Loading branch information
geoffreybauduin committed Nov 24, 2015
2 parents 7d63b61 + 7daeac2 commit c530919
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

```
<input type="text" ng-model="someText" />
<div scroll-pane scroll-config="paneConfig" id="myScrollPane" scroll-always-top="{{someText}}">
<div ng-repeat="item in items track by $index">
<span>{{item}}</span>
</div>
</div>
```

### Reinitialize the pane

If you want to reinitialize the pane, you can broadcast `reinit-pane` with the ID of the DOM Element.
Expand Down
6 changes: 6 additions & 0 deletions src/jscrollpane.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down

0 comments on commit c530919

Please sign in to comment.