Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

ionic Scroll Bar

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.

| | direction
(optional)
| `string` |

The scroll direction. 'x' or 'y'. Default 'y'.

| | paging
(optional)
| `boolean` |

Whether paging scrolls.

| | on-refresh
(optional)
| `expression` |

Trigger pull-to-refresh, byionRefresher.

| | on-scroll
(optional)
| `expression` |

Triggered when the user scrolls.

| | scrollbar-x
(optional)
| `boolean` |

Whether to show the horizontal scroll bar. Default is false.

| | scrollbar-y
(optional)
| `boolean` |

Whether to show the vertical scroll bar. Default is true.

| | zooming
(optional)
| `boolean` |

Whether to support two-finger pinch zoom.

| | min-zoom
(optional)
| `integer` |

The minimum allowed zoom amount (default 0.5)

| | max-zoom
(optional)
| `integer` |

The 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%.

| | icon
(optional)
| `string` |

The 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.

|