Showing
2 changed files
with
14 additions
and
7 deletions
| 1 | -import { Logger, NumberFormatterUtils, DateTimeUtils, EmitterUtils, EmitterEventId, NetworkUtil } from 'wdKit'; | 1 | +import { Logger, NumberFormatterUtils, DateTimeUtils, EmitterUtils, EmitterEventId, NetworkUtil, |
| 2 | + DisplayUtils } from 'wdKit'; | ||
| 2 | import { | 3 | import { |
| 3 | Action, | 4 | Action, |
| 4 | ContentDetailDTO, | 5 | ContentDetailDTO, |
| @@ -41,6 +42,7 @@ export struct ImageAndTextPageComponent { | @@ -41,6 +42,7 @@ export struct ImageAndTextPageComponent { | ||
| 41 | @State publishCommentModel: publishCommentModel = new publishCommentModel() | 42 | @State publishCommentModel: publishCommentModel = new publishCommentModel() |
| 42 | @State operationButtonList: string[] = ['comment', 'collect', 'share'] | 43 | @State operationButtonList: string[] = ['comment', 'collect', 'share'] |
| 43 | @State isNetConnected: boolean = true | 44 | @State isNetConnected: boolean = true |
| 45 | + @State info: Area|null = null | ||
| 44 | 46 | ||
| 45 | build() { | 47 | build() { |
| 46 | Column() { | 48 | Column() { |
| @@ -131,8 +133,11 @@ export struct ImageAndTextPageComponent { | @@ -131,8 +133,11 @@ export struct ImageAndTextPageComponent { | ||
| 131 | Divider().strokeWidth(6).color('#f5f5f5') | 133 | Divider().strokeWidth(6).color('#f5f5f5') |
| 132 | CommentComponent({ | 134 | CommentComponent({ |
| 133 | publishCommentModel: this.publishCommentModel | 135 | publishCommentModel: this.publishCommentModel |
| 136 | + }).onAreaChange((oldValue: Area, newValue: Area) => { | ||
| 137 | + this.info = newValue | ||
| 134 | }) | 138 | }) |
| 135 | // .onMeasureSize() | 139 | // .onMeasureSize() |
| 140 | + | ||
| 136 | } | 141 | } |
| 137 | } | 142 | } |
| 138 | } | 143 | } |
| @@ -144,7 +149,7 @@ export struct ImageAndTextPageComponent { | @@ -144,7 +149,7 @@ export struct ImageAndTextPageComponent { | ||
| 144 | .scrollBar(BarState.Off) | 149 | .scrollBar(BarState.Off) |
| 145 | .align(Alignment.Top) | 150 | .align(Alignment.Top) |
| 146 | 151 | ||
| 147 | - if(!this.isNetConnected) { | 152 | + if (!this.isNetConnected) { |
| 148 | EmptyComponent({ | 153 | EmptyComponent({ |
| 149 | emptyType: 1, | 154 | emptyType: 1, |
| 150 | emptyButton: true, | 155 | emptyButton: true, |
| @@ -152,7 +157,7 @@ export struct ImageAndTextPageComponent { | @@ -152,7 +157,7 @@ export struct ImageAndTextPageComponent { | ||
| 152 | this.getDetail() | 157 | this.getDetail() |
| 153 | } | 158 | } |
| 154 | }) | 159 | }) |
| 155 | - }else{ | 160 | + } else { |
| 156 | if (!this.isPageEnd) { | 161 | if (!this.isPageEnd) { |
| 157 | detailedSkeleton() | 162 | detailedSkeleton() |
| 158 | } | 163 | } |
| @@ -308,7 +313,12 @@ export struct ImageAndTextPageComponent { | @@ -308,7 +313,12 @@ export struct ImageAndTextPageComponent { | ||
| 308 | if (targetId) { | 313 | if (targetId) { |
| 309 | if (targetId == this.publishCommentModel.targetId) { | 314 | if (targetId == this.publishCommentModel.targetId) { |
| 310 | // 滚动到评论列表 | 315 | // 滚动到评论列表 |
| 311 | - | 316 | + if (this.info) { |
| 317 | + // let height = DisplayUtils.getDeviceHeight() / 2 | ||
| 318 | + let offSetY = this.info?.globalPosition.y as number | ||
| 319 | + //头部距离48 | ||
| 320 | + this.scroller.scrollTo({yOffset:offSetY - 100, xOffset:0, animation:{ duration: 1000, curve: Curve.Ease}}) | ||
| 321 | + } | ||
| 312 | } | 322 | } |
| 313 | } | 323 | } |
| 314 | }) | 324 | }) |
| @@ -182,9 +182,6 @@ export struct CommentComponent { | @@ -182,9 +182,6 @@ export struct CommentComponent { | ||
| 182 | if (this.hasMore === false) NoMoreLayout() | 182 | if (this.hasMore === false) NoMoreLayout() |
| 183 | } | 183 | } |
| 184 | } | 184 | } |
| 185 | -// .onScrollFrameBegin((offset: number, state: ScrollState)=>{ | ||
| 186 | -// | ||
| 187 | -// }) | ||
| 188 | .onReachEnd(()=>{ | 185 | .onReachEnd(()=>{ |
| 189 | if (this.hasMore) { | 186 | if (this.hasMore) { |
| 190 | this.getData() | 187 | this.getData() |
-
Please register or login to post a comment