UNPKG

@progress/kendo-vue-dateinputs

Version:
9 lines (8 loc) 2.01 kB
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the package root for more information *------------------------------------------------------------------------------------------- */ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=e=>Math.max(e,0);class l{constructor(t){this.offset=t}}class a{constructor(t){this.skip=t}}class w{constructor(t,s){this.onScrollAction=t,this.onPageAction=s,this.firstLoaded=0,this.bottomOffset=0,this.topOffset=0}create(t,s,r,f,i=0,d=0,h="vertical"){this.rowHeightService=t,this.firstLoaded=s,this.lastLoaded=s+r,this.take=r,this.total=f,this.lastScrollTop=0,this.topOffset=i,this.bottomOffset=d,this.direction=h;const o=this.rowsForHeight(i),c=n(s-o);this.onScrollAction(new l(this.rowOffset(c))),this.onPageAction(new a(c))}onScroll({scrollLeft:t,scrollTop:s,offsetHeight:r,offsetWidth:f}){const i=this.direction==="vertical"?s:t,d=this.direction==="vertical"?r:f;if(this.lastScrollTop===i)return;const h=this.lastScrollTop>=i;this.lastScrollTop=i;const o=this.rowHeightService.index(n(i-this.topOffset)),c=this.rowHeightService.index(n(i+d-this.bottomOffset));if(!h&&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 a(this.firstLoaded))),h&&o<=this.firstLoaded){const S=Math.floor(this.take*.3);this.firstLoaded=n(o-S),this.onScrollAction(new l(this.rowOffset(this.firstLoaded))),this.lastLoaded=Math.min(this.firstLoaded+this.take,this.total),this.onPageAction(new a(this.firstLoaded))}}rowOffset(t){return this.rowHeightService.offset(t)+this.topOffset}rowsForHeight(t){return Math.ceil(t/this.rowHeightService.height(0))}}exports.PageAction=a;exports.ScrollAction=l;exports.ScrollerService=w;