diff --git a/src/main/ets/view/SwipeView.ets b/src/main/ets/view/SwipeView.ets index 8edf13e..b68d066 100644 --- a/src/main/ets/view/SwipeView.ets +++ b/src/main/ets/view/SwipeView.ets @@ -1,3 +1,5 @@ +import { SZYXLocalStorageHelper, ToolsHelper } from '../../../../Index' + @Component export struct SwipeView { private _scroller: Scroller = new Scroller() @@ -5,6 +7,17 @@ export struct SwipeView { @State downX: number = 0 onItemClick?: () => void onDelete?: () => void + ids: string = ToolsHelper.getUuid() + @LocalStorageLink('XBasicSwipeClick') @Watch('onClickIdChange') clickId: string | undefined = undefined + + onClickIdChange() { + if (this.clickId !== this.ids) { + this._scroller.scrollTo({ + xOffset: 0, yOffset: 0, + animation: { duration: 100, curve: Curve.Linear } + }) + } + } @Builder doNothingBuilder() { @@ -20,6 +33,7 @@ export struct SwipeView { Column() { this.customBuilderParam() }.width('100%').onClick(() => { + // SZYXLocalStorageHelper.storage.setOrCreate('XBasicSwipeClick', this.ids) this._scroller.scrollTo({ xOffset: 0, yOffset: 0, animation: { duration: 100, curve: Curve.Linear } @@ -35,6 +49,7 @@ export struct SwipeView { .textAlign(TextAlign.Center) .fontSize(16) .onClick(() => { + // SZYXLocalStorageHelper.storage.setOrCreate('XBasicSwipeClick', this.ids) this._scroller.scrollTo({ xOffset: 0, yOffset: 0, animation: { duration: 100, curve: Curve.Linear } @@ -58,6 +73,7 @@ export struct SwipeView { // 根据触摸类型判断 switch (event.type) { case TouchType.Down: // 触摸按下 + SZYXLocalStorageHelper.storage.setOrCreate('XBasicSwipeClick', this.ids) // 记录按下的x轴坐标 this.downX = event.touches[0].x break