@progress/kendo-vue-dateinputs
Version:
52 lines (51 loc) • 2.27 kB
JavaScript
/**
* @license
*-------------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the package root for more information
*-------------------------------------------------------------------------------------------
*/
const n = (e) => Math.max(e, 0);
class l {
constructor(t) {
this.offset = t;
}
}
class d {
constructor(t) {
this.skip = t;
}
}
class S {
constructor(t, i) {
this.onScrollAction = t, this.onPageAction = i, this.firstLoaded = 0, this.bottomOffset = 0, this.topOffset = 0;
}
create(t, i, h, a, s = 0, f = 0, r = "vertical") {
this.rowHeightService = t, this.firstLoaded = i, this.lastLoaded = i + h, this.take = h, this.total = a, this.lastScrollTop = 0, this.topOffset = s, this.bottomOffset = f, this.direction = r;
const o = this.rowsForHeight(s), c = n(i - o);
this.onScrollAction(new l(this.rowOffset(c))), this.onPageAction(new d(c));
}
onScroll({ scrollLeft: t, scrollTop: i, offsetHeight: h, offsetWidth: a }) {
const s = this.direction === "vertical" ? i : t, f = this.direction === "vertical" ? h : a;
if (this.lastScrollTop === s)
return;
const r = this.lastScrollTop >= s;
this.lastScrollTop = s;
const o = this.rowHeightService.index(n(s - this.topOffset)), c = this.rowHeightService.index(n(s + f - this.bottomOffset));
if (!r && c >= this.lastLoaded && this.lastLoaded < this.total && (this.firstLoaded = o, this.onScrollAction(new l(this.rowOffset(o))), this.lastLoaded = Math.min(this.firstLoaded + this.take, this.total), this.onPageAction(new d(this.firstLoaded))), r && o <= this.firstLoaded) {
const w = Math.floor(this.take * 0.3);
this.firstLoaded = n(o - w), this.onScrollAction(new l(this.rowOffset(this.firstLoaded))), this.lastLoaded = Math.min(this.firstLoaded + this.take, this.total), this.onPageAction(new d(this.firstLoaded));
}
}
rowOffset(t) {
return this.rowHeightService.offset(t) + this.topOffset;
}
rowsForHeight(t) {
return Math.ceil(t / this.rowHeightService.height(0));
}
}
export {
d as PageAction,
l as ScrollAction,
S as ScrollerService
};