From d48dc4296a314f2af393f5156073279bf6109574 Mon Sep 17 00:00:00 2001 From: zhangrongjie Date: Tue, 29 Nov 2022 11:55:08 +0800 Subject: [PATCH] fix nested scroll Signed-off-by: zhangrongjie Change-Id: Iff9e0cf088cf9d4144cff87c4ceaf00d75c93c4f --- .../reference/arkui-ts/ts-container-scroll.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-scroll.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-scroll.md index 4afb957f54..e45219eff3 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-scroll.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-scroll.md @@ -236,20 +236,21 @@ struct ScrollExample { struct NestedScroll { @State listPosition: number = 0; // 0代表滚动到List顶部,1代表中间值,2代表滚动到List底部。 private arr: number[] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] - private scroller: Scroller = new Scroller() + private scrollerForScroll: Scroller = new Scroller() + private scrollerForList: Scroller = new Scroller() build() { Flex() { - Scroll(this.scroller) { + Scroll(this.scrollerForScroll) { Column() { Text("Scroll Area") .width("100%").height("40%").backgroundColor(0X330000FF) .fontSize(16).textAlign(TextAlign.Center) .onClick(() => { - this.scroller.scrollToIndex(5) + this.scrollerForList.scrollToIndex(5) }) - List({ space: 20, scroller: this.scroller }) { + List({ space: 20, scroller: this.scrollerForList }) { ForEach(this.arr, (item) => { ListItem() { Text("ListItem" + item) @@ -269,7 +270,7 @@ struct NestedScroll { }) .onScrollBegin((dx: number, dy: number) => { if ((this.listPosition == 0 && dy >= 0) || (this.listPosition == 2 && dy <= 0)) { - this.scroller.scrollBy(0, -dy) + this.scrollerForScroll.scrollBy(0, -dy) return { dxRemain: dx, dyRemain: 0 } } this.listPosition = 1 -- GitLab