Skip to content

Commit 5b54a79

Browse files
committed
Adapter isEmpty() public method, tests coverage
1 parent 222e321 commit 5b54a79

File tree

4 files changed

+198
-144
lines changed

4 files changed

+198
-144
lines changed

README.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,10 @@ The adapter object is an internal object created for every instance of the scrol
127127

128128
Adapter object implements the following properties:
129129

130-
* `isLoading` - a boolean value indicating whether there are any pending load requests.
131-
* `topVisible` - a reference to the item currently in the topmost visible position.
132-
* `topVisibleElement` - a reference to the DOM element currently in the topmost visible position.
133-
* `topVisibleScope` - a reference to the scope created for the item currently in the topmost visible position.
130+
* `isLoading` - a boolean value (read only) indicating whether there are any pending load requests.
131+
* `topVisible` - a read only reference to the item currently in the topmost visible position.
132+
* `topVisibleElement` - a read only reference to the DOM element currently in the topmost visible position.
133+
* `topVisibleScope` - a read only reference to the scope created for the item currently in the topmost visible position.
134134
* `disabled` - setting `disabled` to `true` disables scroller's scroll/resize events handlers. This can be useful if you have multiple scrollers within the same scrollViewport and you want to prevent some of them from responding to the events.
135135

136136
Adapater object implements the following methods
@@ -147,7 +147,14 @@ Adapater object implements the following methods
147147
isEOF()
148148

149149
#### Description
150-
returns `true` if the last item of the dataset is already in the buffer. No further requests for tailing items will be issued, returns `false` otherwise,
150+
returns `true` if the last item of the dataset is already in the buffer. No further requests for tailing items will be issued, returns `false` otherwise.
151+
152+
* Method `isEmpty`
153+
154+
isEmpty()
155+
156+
#### Description
157+
returns `true` if the dataset is empty and the internal buffer length = 0. Returns `false` otherwise. Mind that isEmpty() will return `true` during the **first** request is pending, so maybe it should be used together with `isLoading` property.
151158

152159
* Method `reload`
153160

src/modules/adapter.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export default function Adapter($rootScope, $parse, $attr, viewport, buffer, adj
1919
this.isLoading = false;
2020
this.isBOF = () => buffer.bof;
2121
this.isEOF = () => buffer.eof;
22+
this.isEmpty = () => !buffer.length;
2223

2324
this.applyUpdates = (arg1, arg2) => {
2425
if (angular.isFunction(arg1)) {

src/ui-scroll.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ import Viewport from './modules/viewport.js';
55
import Adapter from './modules/adapter.js';
66

77
angular.module('ui.scroll', [])
8+
89
.service('jqLiteExtras', () => new JQLiteExtras())
910
.run(['jqLiteExtras', (jqLiteExtras) =>
1011
!window.jQuery ? jqLiteExtras.registerFor(angular.element) : null
1112
])
13+
1214
.directive('uiScrollViewport', function () {
1315
return {
1416
restrict: 'A',
@@ -30,6 +32,7 @@ angular.module('ui.scroll', [])
3032
]
3133
};
3234
})
35+
3336
.directive('uiScroll', [
3437
'$log',
3538
'$injector',
@@ -48,7 +51,6 @@ angular.module('ui.scroll', [])
4851
link: link
4952
};
5053

51-
5254
function link($scope, element, $attr, controllers, linker) {
5355
const match = $attr.uiScroll.match(/^\s*(\w+)\s+in\s+([(\w|\$)\.]+)\s*$/);
5456
if (!match) {

0 commit comments

Comments
 (0)