Skip to content

Commit 2069c3c

Browse files
Portugal, Marcelomportuga
authored andcommitted
feat(custom-scrolling): Documenting custom scrolling feature.
Removing custom scrolling directive in favor of making it a thirdparty plugin and adding proper documentation for the customScroller method in gridOptions.
1 parent de0116e commit 2069c3c

File tree

6 files changed

+63
-571
lines changed

6 files changed

+63
-571
lines changed

misc/tutorial/299_third_party_features.ngdoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@ Allows querying for odata v3/v4 services
1919
### **ui-grid-auto-scroll** ###
2020
Auto scrolls when new data is added to the grid
2121
<br>https://github.com/stevezau/ui-grid-auto-scroll
22+
23+
### **ui-grid-custom-scroller** ###
24+
The custom scroller takes over the default scrolling logic in order to ensure that grid scrolling works without a lag on devices.
25+
<br>https://github.com/mportuga/ui-grid-custom-scroller

misc/tutorial/407_custom_scrolling.ngdoc

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,40 @@
22
@name Tutorial: 407 Custom Scrolling
33
@description
44

5-
<div class="alert alert-info" role="alert"><strong>Note</strong> It is highly recommended that you turn this feature on alongside pinning, especially
6-
if you plan on using ui-grid on devices.</div>
7-
8-
The custom scrolling feature takes over the default scrolling logic in order to ensure that grid scrolling works without a lag on devices.
9-
To enable, you must include the 'ui.grid.customScrolling' module and you must include the ui-grid-custom-scrolling directive on your grid element.
5+
The custom scrolling feature allows you to provide your own scroller function to replace default element.on('scroll') function. It is particularly
6+
helpful if you are facing issues with scrolling on devices or slow machines, because it allows you to use thirdparty scrollers.
107

118
Documentation for the custom scrolling feature is provided in the api documentation, in particular:
129

13-
- {@link api/ui.grid.customScrolling.constant:uiGridScrollerConstants uiGridScrollerConstants}
14-
- {@link api/ui.grid.customScrolling.service:uiGridScroller uiGridScroller}
15-
- {@link api/ui.grid.customScrolling.directive:uiGridCustomScrolling uiGridCustomScrolling}
10+
- {@link api/ui.grid.class:GridOptions customScroller}
1611

1712
@example
1813
<example module="app">
1914
<file name="app.js">
20-
var app = angular.module('app', ['ngTouch', 'ui.grid', 'ui.grid.pinning', 'ui.grid.customScrolling']);
15+
var app = angular.module('app', ['ngTouch', 'ui.grid']);
2116

2217
app.controller('MainCtrl', ['$scope', '$http', '$log', function ($scope, $http, $log) {
23-
$scope.gridOptions = {};
18+
$scope.scroll ={
19+
top: 0,
20+
left: 0
21+
};
22+
23+
$scope.gridOptions = {
24+
customScroller: function myScrolling(uiGridViewport, scrollHandler) {
25+
uiGridViewport.on('scroll', function myScrollingOverride(event) {
26+
$scope.scroll.top = uiGridViewport[0].scrollTop;
27+
$scope.scroll.left = uiGridViewport[0].scrollLeft;
28+
29+
// You should always pass the event to the callback since ui-grid needs it
30+
scrollHandler(event);
31+
});
32+
}
33+
};
2434

2535
$scope.gridOptions.columnDefs = [
26-
{ name:'id', width:50, enablePinning:false },
27-
{ name:'name', width:100, pinnedLeft:true },
28-
{ name:'age', width:100, pinnedRight:true },
36+
{ name:'id', width:50 },
37+
{ name:'name', width:100 },
38+
{ name:'age', width:100 },
2939
{ name:'address.street', width:150 },
3040
{ name:'address.city', width:150 },
3141
{ name:'address.state', width:50 },
@@ -47,7 +57,17 @@ Documentation for the custom scrolling feature is provided in the api documentat
4757
</file>
4858
<file name="index.html">
4959
<div ng-controller="MainCtrl">
50-
<div ui-grid="gridOptions" class="grid" ui-grid-pinning ui-grid-custom-scrolling></div>
60+
<div class="row">
61+
<label class="col-sm-2">Scroll Top: </label>
62+
<div class="col-sm-4">
63+
{{ scroll.top }}
64+
</div>
65+
<label class="col-sm-2">Scroll Left: </label>
66+
<div class="col-sm-4">
67+
{{ scroll.left }}
68+
</div>
69+
</div>
70+
<div ui-grid="gridOptions" class="grid"></div>
5171
</div>
5272
</file>
5373
<file name="main.css">

0 commit comments

Comments
 (0)