Toggle navigation
Toggle navigation
This project
Loading...
Sign in
developOne
/
harmonyPool
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
chenquansheng
2024-08-09 14:20:17 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
6a42c69f4c0b1e8a9b935ac48d439df709162e0b
6a42c69f
1 parent
f6ad2cc5
fix |> 修复在新闻详情页评论后自动弹回详情页顶部问题
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
7 deletions
sight_harmony/features/wdComponent/src/main/ets/components/ImageAndTextPageComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/ImageAndTextPageComponent.ets
View file @
6a42c69
...
...
@@ -5,6 +5,7 @@ import {
EmitterUtils,
EmitterEventId,
NetworkUtil,
DisplayUtils
} from 'wdKit';
import {
Action,
...
...
@@ -65,6 +66,9 @@ export struct ImageAndTextPageComponent {
@State isScrollTop: boolean = true
@State offsetY: number = 0
@State executedStartTime: number = new Date().getTime()
private screenHeight: number = 0
private topHeight: number = 32
private bottomHeight: number = 150
pageShowTime:number = 0;
pageHideTime:number = 0;
lastTimeoutId?: number
...
...
@@ -160,7 +164,7 @@ export struct ImageAndTextPageComponent {
.onAreaChange((oldValue: Area, newValue: Area) => {
this.info = newValue
console.log(TAG, "总页面滑动偏移量", this.scroller.currentOffset().yOffset)
this.checkToScrollCommentArea()
})
// .onMeasureSize()
...
...
@@ -206,7 +210,7 @@ export struct ImageAndTextPageComponent {
styleType: 1,
onCommentIconClick: () => {
const info = componentUtils.getRectangleById('comment');
console.log(JSON.stringify(info))
console.log(
TAG, "点击滑动页面",
JSON.stringify(info))
if (!this.offsetY) {
this.offsetY = componentUtils.getRectangleById('comment').windowOffset.y
...
...
@@ -229,7 +233,7 @@ export struct ImageAndTextPageComponent {
.position({y:'85%'})
.width(CommonConstants.FULL_WIDTH)
.backgroundColor(Color.White)
.height(
150
)
.height(
this.bottomHeight
)
// 发布时间
Column() {
...
...
@@ -244,7 +248,7 @@ export struct ImageAndTextPageComponent {
}
}
.width(CommonConstants.FULL_WIDTH)
.height(
32
)
.height(
this.topHeight
)
.padding({ left: 15, right: 15, })
.justifyContent(FlexAlign.SpaceBetween)
.alignItems(VerticalAlign.Bottom)
...
...
@@ -444,6 +448,7 @@ export struct ImageAndTextPageComponent {
aboutToAppear() {
this.getDetail()
this.screenHeight = DisplayUtils.getDeviceHeight()
//注册通知,来自别的组件的评论成功通知
EmitterUtils.receiveEvent(EmitterEventId.COMMENT_PUBLISH, (targetId?: string) => {
if (targetId) {
...
...
@@ -451,11 +456,22 @@ export struct ImageAndTextPageComponent {
// 滚动到评论列表
if (this.info) {
// let height = DisplayUtils.getDeviceHeight() / 2
let offSetY = this.info?.globalPosition.y as number
Logger.debug(TAG, "滚动至yOffset: " + (offSetY - 100))
//评论区当前位置
let currentCommonentOffSetY = this.info?.globalPosition.y as number
//当前页面滚动的位置
let currentScrollOffSetY = this.scroller.currentOffset().yOffset
if (currentCommonentOffSetY > 0 && currentCommonentOffSetY < (this.screenHeight-this.bottomHeight)){
return
}
let offSetY = currentScrollOffSetY
if (currentCommonentOffSetY > (this.screenHeight-this.bottomHeight) ) {
offSetY = currentCommonentOffSetY-200
}else {
offSetY = currentScrollOffSetY + currentCommonentOffSetY-100
}
//头部距离48
this.scroller.scrollTo({
yOffset: offSetY
- 100
,
yOffset: offSetY,
xOffset: 0,
animation: { duration: 1000, curve: Curve.Ease }
})
...
...
Please
register
or
login
to post a comment