Showing
1 changed file
with
11 additions
and
13 deletions
| @@ -65,7 +65,6 @@ export struct ImageAndTextPageComponent { | @@ -65,7 +65,6 @@ export struct ImageAndTextPageComponent { | ||
| 65 | @State reachEndIncreament: number = 0 | 65 | @State reachEndIncreament: number = 0 |
| 66 | @State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0 | 66 | @State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0 |
| 67 | @State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0 | 67 | @State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0 |
| 68 | - @State isScrollTop: boolean = true | ||
| 69 | @State offsetY: number = 0 | 68 | @State offsetY: number = 0 |
| 70 | @State executedStartTime: number = new Date().getTime() | 69 | @State executedStartTime: number = new Date().getTime() |
| 71 | private screenHeight: number = 0 | 70 | private screenHeight: number = 0 |
| @@ -208,8 +207,9 @@ export struct ImageAndTextPageComponent { | @@ -208,8 +207,9 @@ export struct ImageAndTextPageComponent { | ||
| 208 | 207 | ||
| 209 | .onAreaChange((oldValue: Area, newValue: Area) => { | 208 | .onAreaChange((oldValue: Area, newValue: Area) => { |
| 210 | this.info = newValue | 209 | this.info = newValue |
| 211 | - // console.log(TAG, "总页面滑动偏移量", this.scroller.currentOffset().yOffset) | ||
| 212 | - // console.log(TAG, "总页面滑动偏移量111", newValue.globalPosition.y as number) | 210 | + // console.log(TAG, ">>>>>当前页面滚动位置:", this.scroller.currentOffset().yOffset) |
| 211 | + // console.log(TAG, ">>>>>当前评论区位置:", newValue.globalPosition.y as number) | ||
| 212 | + // console.log(TAG, ">>>>>当前屏幕宽度和底部高度:", this.screenHeight,this.bottomHeight) | ||
| 213 | this.checkToScrollCommentArea() | 213 | this.checkToScrollCommentArea() |
| 214 | }) | 214 | }) |
| 215 | // .onMeasureSize() | 215 | // .onMeasureSize() |
| @@ -467,7 +467,7 @@ export struct ImageAndTextPageComponent { | @@ -467,7 +467,7 @@ export struct ImageAndTextPageComponent { | ||
| 467 | * 查询点赞、收藏数量 | 467 | * 查询点赞、收藏数量 |
| 468 | */ | 468 | */ |
| 469 | queryContentInteractCount() { | 469 | queryContentInteractCount() { |
| 470 | - console.error(TAG, 'contentDetailData2222', JSON.stringify(this.contentDetailData)) | 470 | + // console.error(TAG, 'contentDetailData2222', JSON.stringify(this.contentDetailData)) |
| 471 | 471 | ||
| 472 | const params: contentInteractParams = { | 472 | const params: contentInteractParams = { |
| 473 | contentId: this.contentDetailData?.newsId + '', | 473 | contentId: this.contentDetailData?.newsId + '', |
| @@ -504,16 +504,16 @@ export struct ImageAndTextPageComponent { | @@ -504,16 +504,16 @@ export struct ImageAndTextPageComponent { | ||
| 504 | 504 | ||
| 505 | private pageScrollToCommonent() { | 505 | private pageScrollToCommonent() { |
| 506 | const info = componentUtils.getRectangleById('comment'); | 506 | const info = componentUtils.getRectangleById('comment'); |
| 507 | - console.log(TAG, "点击滑动页面", JSON.stringify(info)) | ||
| 508 | //评论区当前位置 | 507 | //评论区当前位置 |
| 509 | - let currentCommonentOffSetY = this.info?.globalPosition.y as number | 508 | + let currentCommonentOffSetY = this.info?.globalPosition.y as number - 70 |
| 509 | + // 当前页面滚动位置 | ||
| 510 | + let currentScrollOffSetY = this.scroller.currentOffset().yOffset | ||
| 510 | let offSetY = 0 | 511 | let offSetY = 0 |
| 511 | if (currentCommonentOffSetY >= (this.screenHeight-this.bottomHeight) ) { | 512 | if (currentCommonentOffSetY >= (this.screenHeight-this.bottomHeight) ) { |
| 512 | - offSetY = currentCommonentOffSetY-200 | 513 | + offSetY = currentScrollOffSetY + (currentCommonentOffSetY - this.screenHeight+this.bottomHeight) + 400 |
| 513 | } | 514 | } |
| 514 | - | ||
| 515 | // 定位到评论区域 | 515 | // 定位到评论区域 |
| 516 | - if (this.isScrollTop) { | 516 | + if (!this.showMainText) { |
| 517 | this.scroller.scrollTo({ | 517 | this.scroller.scrollTo({ |
| 518 | xOffset: 0, | 518 | xOffset: 0, |
| 519 | yOffset: offSetY, | 519 | yOffset: offSetY, |
| @@ -522,11 +522,10 @@ export struct ImageAndTextPageComponent { | @@ -522,11 +522,10 @@ export struct ImageAndTextPageComponent { | ||
| 522 | } else { | 522 | } else { |
| 523 | this.scroller.scrollEdge(Edge.Top) | 523 | this.scroller.scrollEdge(Edge.Top) |
| 524 | } | 524 | } |
| 525 | - this.isScrollTop = !this.isScrollTop | ||
| 526 | } | 525 | } |
| 527 | 526 | ||
| 528 | aboutToAppear() { | 527 | aboutToAppear() { |
| 529 | - Logger.debug(TAG, '文章详情页 aboutToAppear,开始请求接口数据'); | 528 | + // Logger.debug(TAG, '文章详情页 aboutToAppear,开始请求接口数据'); |
| 530 | this.getDetail() | 529 | this.getDetail() |
| 531 | this.screenHeight = DisplayUtils.getDeviceHeight() | 530 | this.screenHeight = DisplayUtils.getDeviceHeight() |
| 532 | this.initAnimationConfig(); | 531 | this.initAnimationConfig(); |
| @@ -576,8 +575,7 @@ export struct ImageAndTextPageComponent { | @@ -576,8 +575,7 @@ export struct ImageAndTextPageComponent { | ||
| 576 | // 需要评论区位置,调用前 请确保它有值 | 575 | // 需要评论区位置,调用前 请确保它有值 |
| 577 | return | 576 | return |
| 578 | } | 577 | } |
| 579 | - let offSetY = this.info?.globalPosition.y as number -60 | ||
| 580 | - Logger.debug(TAG, "即将滚动至yOffset: " + offSetY) | 578 | + let offSetY = this.info?.globalPosition.y as number -70 |
| 581 | if (offSetY >= (this.screenHeight-this.bottomHeight) ) { | 579 | if (offSetY >= (this.screenHeight-this.bottomHeight) ) { |
| 582 | this.showMainText = false | 580 | this.showMainText = false |
| 583 | }else { | 581 | }else { |
-
Please register or login to post a comment