Skip to content

Commit

Permalink
feature/scroll-top — Allows to scroll back to the top of an ion conte…
Browse files Browse the repository at this point in the history
…nt by clicking the view title.

Useful on android cause it is not built-in like in iOS (status bar).
  • Loading branch information
jeandat committed Feb 11, 2016
1 parent 73a54f5 commit bc182b3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/app.jade
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ html

ion-nav-view

scroll-top

// I'm not concatenating vendors to ease debugging without source maps.
// In a cordova app, we can afford it.
script(src='js/jquery.js')
Expand Down
32 changes: 32 additions & 0 deletions app/common/scroll-top/scroll-top.directive.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
(function () {
'use strict';

angular
.module('app')
.directive('scrollTop', scrollTopDirective);

function scrollTopDirective($ionicScrollDelegate) {

var directive = {
link: link,
restrict: 'E',
scope: {}
};
return directive;

////////////

function link(scope) {
$('ion-nav-bar').on('click', '.title', function(){
scope.$apply(scrollTop);
});
}

function scrollTop(){
$ionicScrollDelegate.scrollTop(true);
}

}

})();

0 comments on commit bc182b3

Please sign in to comment.