vscroll
Version:
Virtual scroll engine
40 lines • 1.63 kB
JavaScript
import { __extends } from "tslib";
import { BaseAdapterProcessFactory, AdapterProcess, ProcessStatus } from '../misc/index';
import { Direction } from '../../inputs/index';
var Check = /** @class */ (function (_super) {
__extends(Check, _super);
function Check() {
return _super !== null && _super.apply(this, arguments) || this;
}
Check.run = function (scroller) {
var workflow = scroller.workflow, buffer = scroller.buffer, fetch = scroller.state.fetch, viewport = scroller.viewport;
var min = Infinity, max = -Infinity;
buffer.items.forEach(function (item) {
var size = item.size;
item.setSize();
if (item.size !== size) {
buffer.cacheItem(item);
min = Math.min(min, item.$index);
max = Math.max(max, item.$index);
}
});
if (Number.isFinite(min)) {
fetch.first.indexBuffer = buffer.firstIndex;
fetch.last.indexBuffer = buffer.lastIndex;
var _a = viewport.getEdgeVisibleItem(buffer.items, Direction.backward), firstIndex = _a.index, diff = _a.diff;
fetch.firstVisible.index = firstIndex;
if (!isNaN(firstIndex)) {
fetch.firstVisible.delta = -buffer.getSizeByIndex(firstIndex) + diff;
}
fetch.check(buffer.items.filter(function (item) { return item.$index >= min && item.$index <= max; }));
}
scroller.logger.stat('check');
workflow.call({
process: Check.process,
status: Number.isFinite(min) ? ProcessStatus.next : ProcessStatus.done
});
};
return Check;
}(BaseAdapterProcessFactory(AdapterProcess.check)));
export default Check;
//# sourceMappingURL=check.js.map