chenquansheng

fix |> 修复稿件详情页评论区域滚动到可视区域的问题

... ... @@ -65,7 +65,6 @@ export struct ImageAndTextPageComponent {
@State reachEndIncreament: number = 0
@State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0
@State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0
@State isScrollTop: boolean = true
@State offsetY: number = 0
@State executedStartTime: number = new Date().getTime()
private screenHeight: number = 0
... ... @@ -208,8 +207,9 @@ export struct ImageAndTextPageComponent {
.onAreaChange((oldValue: Area, newValue: Area) => {
this.info = newValue
// console.log(TAG, "总页面滑动偏移量", this.scroller.currentOffset().yOffset)
// console.log(TAG, "总页面滑动偏移量111", newValue.globalPosition.y as number)
// console.log(TAG, ">>>>>当前页面滚动位置:", this.scroller.currentOffset().yOffset)
// console.log(TAG, ">>>>>当前评论区位置:", newValue.globalPosition.y as number)
// console.log(TAG, ">>>>>当前屏幕宽度和底部高度:", this.screenHeight,this.bottomHeight)
this.checkToScrollCommentArea()
})
// .onMeasureSize()
... ... @@ -467,7 +467,7 @@ export struct ImageAndTextPageComponent {
* 查询点赞、收藏数量
*/
queryContentInteractCount() {
console.error(TAG, 'contentDetailData2222', JSON.stringify(this.contentDetailData))
// console.error(TAG, 'contentDetailData2222', JSON.stringify(this.contentDetailData))
const params: contentInteractParams = {
contentId: this.contentDetailData?.newsId + '',
... ... @@ -504,16 +504,16 @@ export struct ImageAndTextPageComponent {
private pageScrollToCommonent() {
const info = componentUtils.getRectangleById('comment');
console.log(TAG, "点击滑动页面", JSON.stringify(info))
//评论区当前位置
let currentCommonentOffSetY = this.info?.globalPosition.y as number
let currentCommonentOffSetY = this.info?.globalPosition.y as number - 70
// 当前页面滚动位置
let currentScrollOffSetY = this.scroller.currentOffset().yOffset
let offSetY = 0
if (currentCommonentOffSetY >= (this.screenHeight-this.bottomHeight) ) {
offSetY = currentCommonentOffSetY-200
offSetY = currentScrollOffSetY + (currentCommonentOffSetY - this.screenHeight+this.bottomHeight) + 400
}
// 定位到评论区域
if (this.isScrollTop) {
if (!this.showMainText) {
this.scroller.scrollTo({
xOffset: 0,
yOffset: offSetY,
... ... @@ -522,11 +522,10 @@ export struct ImageAndTextPageComponent {
} else {
this.scroller.scrollEdge(Edge.Top)
}
this.isScrollTop = !this.isScrollTop
}
aboutToAppear() {
Logger.debug(TAG, '文章详情页 aboutToAppear,开始请求接口数据');
// Logger.debug(TAG, '文章详情页 aboutToAppear,开始请求接口数据');
this.getDetail()
this.screenHeight = DisplayUtils.getDeviceHeight()
this.initAnimationConfig();
... ... @@ -576,8 +575,7 @@ export struct ImageAndTextPageComponent {
// 需要评论区位置,调用前 请确保它有值
return
}
let offSetY = this.info?.globalPosition.y as number -60
Logger.debug(TAG, "即将滚动至yOffset: " + offSetY)
let offSetY = this.info?.globalPosition.y as number -70
if (offSetY >= (this.screenHeight-this.bottomHeight) ) {
this.showMainText = false
}else {
... ...