ionic Scroll Bar
ion-scroll
ion-scroll is used to create a scrollable container.
Usage
...
API
| property | Type | Details |
|---|---|---|
| delegate-handle |
(optional)
| `string` |This handle uses$ionicScrollDelegateto specify the scroll view.
The scroll direction. 'x' or 'y'. Default 'y'.
| | pagingWhether paging scrolls.
| | on-refreshTrigger pull-to-refresh, byionRefresher.
Triggered when the user scrolls.
| | scrollbar-xWhether to show the horizontal scroll bar. Default is false.
| | scrollbar-yWhether to show the vertical scroll bar. Default is true.
| | zoomingWhether to support two-finger pinch zoom.
| | min-zoomThe minimum allowed zoom amount (default 0.5)
| | max-zoomThe maximum allowed zoom amount (default 3)
|Example
HTML Code
CSS code
body {
cursor: url('http://www.runoob.com/try/demo_source/finger.png'), auto;
}
JavaScript Code
angular.module('ionicApp', ['ionic']);
ion-infinite-scroll
When the user reaches or approaches the footer, the ionInfiniteScroll directive allows you to call a function.
When the user scrolls beyond the content at the bottom, the on-infinite you specified is triggered.
Usage
function MyController($scope, $http) {
$scope.items = [];
$scope.loadMore = function() {
$http.get('/more-items').success(function(items) {
useItems(items);
$scope.$broadcast('scroll.infiniteScrollComplete');
});
};
$scope.$on('stateChangeSuccess', function() {
$scope.loadMore();
});
}
When there is no more data to load, a simple way to stop infinite scrolling is Angular's ng-if directive:
API
| property | Type | Details |
|---|---|---|
| on-infinite | 表达式 |
The event triggered when scrolling to the bottom. |
| distance |
(optional)
| `string` |The distance from the bottom at which the on-infinite expression is triggered. Default: 1%.
| | iconThe icon shown while loading. Default: 'ion-loading-d'.
|$ionicScrollDelegate
Authorization to control the scroll view (created via the ion-content and ion-scroll directives).
This method is triggered directly by the $ionicScrollDelegate service to control all scroll views. Use the $getByHandle method to control a specific scroll view.
Usage
function MainCtrl($scope, $ionicScrollDelegate) {
$scope.scrollTop = function() {
$ionicScrollDelegate.scrollTop();
};
}
Method
resize()
Tells the scroll view to recalculate its container size.
scrollTop([shouldAnimate])
| Parameters | Type | Details |
|---|---|---|
| shouldAnimate |
(optional)
| `boolean` |Whether to apply scroll animations.
|
scrollBottom([shouldAnimate])
| Parameters | Type | Details |
|---|---|---|
| shouldAnimate |
(optional)
| `boolean` |Whether to apply scroll animations.
|