Skip to content

Commit 4acd507

Browse files
committed
issue-225 infinite mode doClip issue + spec
1 parent cb1886d commit 4acd507

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

src/component/processes/preClip.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,33 @@ export default class PreClip {
1818
}
1919

2020
static prepareClip(scroller: Scroller) {
21-
const { state: { fetch, fetch: { direction } } } = scroller;
21+
const { state: { fetch, clip } } = scroller;
2222
if (PreClip.shouldNotClip(scroller)) {
2323
return;
2424
}
2525
const firstIndex = fetch.first.indexBuffer as number;
2626
const lastIndex = fetch.last.indexBuffer as number;
2727
scroller.logger.log(() =>
28-
`looking for ${direction ? 'anti-' + direction + ' ' : ''}items ` +
28+
`looking for ${fetch.direction ? 'anti-' + fetch.direction + ' ' : ''}items ` +
2929
`that are out of [${firstIndex}..${lastIndex}] range`);
3030
if (PreClip.isBackward(scroller, firstIndex)) {
3131
PreClip.prepareClipByDirection(scroller, Direction.backward, firstIndex);
3232
}
3333
if (PreClip.isForward(scroller, lastIndex)) {
3434
PreClip.prepareClipByDirection(scroller, Direction.forward, lastIndex);
3535
}
36-
if (!scroller.state.clip.doClip) {
36+
if (!clip.doClip) {
3737
scroller.logger.log(`skipping clip [no items to clip]`);
3838
}
3939
return;
4040
}
4141

4242
static shouldNotClip(scroller: Scroller): boolean {
43-
const { buffer, state } = scroller;
43+
const { settings, buffer, state } = scroller;
44+
if (settings.infinite) {
45+
scroller.logger.log(`skipping clip [infinite mode]`);
46+
return true;
47+
}
4448
if (!buffer.size) {
4549
scroller.logger.log(`skipping clip [empty buffer]`);
4650
return true;

tests/bug.spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,4 +240,20 @@ describe('Bug Spec', () => {
240240
})
241241
);
242242

243+
describe('infinite mode', () =>
244+
makeTest({
245+
title: 'should stop after scroll',
246+
config: {
247+
datasourceName: 'default-delay-25',
248+
datasourceSettings: { adapter: true, bufferSize: 50, infinite: true },
249+
},
250+
it: (misc: Misc) => async (done: Function) => {
251+
await misc.relaxNext();
252+
misc.scrollMin();
253+
await misc.relaxNext();
254+
done();
255+
}
256+
})
257+
);
258+
243259
});

0 commit comments

Comments
 (0)