diff --git a/doric-web/src/shader/DoricListNode.ts b/doric-web/src/shader/DoricListNode.ts index 43f7075a..996c4724 100644 --- a/doric-web/src/shader/DoricListNode.ts +++ b/doric-web/src/shader/DoricListNode.ts @@ -5,6 +5,7 @@ export class DoricListNode extends DoricSuperNode { itemCount = 0 renderItemFuncId?: string onLoadMoreFuncId?: string + onScrollFuncId?: string loadMoreViewId?: string batchCount = 15 loadMore = false @@ -22,6 +23,9 @@ export class DoricListNode extends DoricSuperNode { case "onLoadMore": this.onLoadMoreFuncId = prop as string break + case "onScroll": + this.onScrollFuncId = prop as string + break case "loadMoreView": this.loadMoreViewId = prop as string break @@ -114,7 +118,11 @@ export class DoricListNode extends DoricSuperNode { build() { const ret = document.createElement('div') ret.style.overflow = "scroll" - ret.addEventListener("scroll", () => { + ret.addEventListener("scroll", event => { + if (this.onScrollFuncId) { + this.callJSResponse(this.onScrollFuncId, + { x: (event.target as HTMLElement).scrollLeft || 0, y: (event.target as HTMLElement).scrollTop }) + } if (this.loadMore) { if (ret.scrollTop + ret.offsetHeight === ret.scrollHeight) { this.onScrollToEnd()