Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PullDownRefresh] 可视内容高度为固定时,滚动里边内容,现在设置scrollTop属性值为0,里边内容并没有回到最顶端显示 #2579

Closed
315574925 opened this issue Jan 29, 2024 · 8 comments
Labels
duplicate This issue or pull request already exists

Comments

@315574925
Copy link

tdesign-miniprogram 版本

v1.2.6

重现链接

No response

重现步骤

可视内容高度为固定时,滚动里边内容,现在设置scrollTop属性值为0,里边内容并没有回到最顶端显示

期望结果

应该重置到初始状态,因为比如现在滚动到列表中间,现在我从新搜索列表,搜索到的结果再列表时,应该从最顶部内容开始浏览

实际结果

可视内容高度为固定时,滚动里边内容,现在设置scrollTop属性值为0,里边内容并没有回到最顶端显示

基础库版本

No response

补充说明

No response

Copy link
Contributor

👋 @315574925,感谢给 TDesign 提出了 issue。
请根据 issue 模版确保背景信息的完善,我们将调查并尽快回复你。

@lisashare
Copy link

我也有需要回到顶部的需求,数据刷新了,列表没有回到顶部,

@lisashare
Copy link

源码中已经有回到顶部的scrollToTop函数了。修改源码,在传递组件value值的时候,值为true就设置scrollToTop()函数就好了,希望下个版本能更新或者暴露api

@315574925
Copy link
Author

315574925 commented Jan 31, 2024

scrollToTop
@lisashare
可以贴下代码不呢?

@lisashare
Copy link

这种修改方式更改了源码,我是不想重写功能了,每次构建npm需要手动添加,坐等官方组件更新吧~
\miniprogram\miniprogram_npm\tdesign-miniprogram\pull-down-refresh\pull-down-refresh.js
this.observers = {
value(val) {
if (!val) {
clearTimeout(this.maxRefreshAnimateTimeFlag);
if (this.data.refreshStatus > 0) {
this.setData({
refreshStatus: 3,
});
}
this.setData({ barHeight: 0 });
}
else {
this.doRefresh();
// todo
this.scrollToTop() // 这里添加回到顶部函数(实际这个js methods中已经提供了回到顶部的方法了)
}
}
};

@315574925
Copy link
Author

scrollToTop
@lisashare
我看了下确实是有对应方法 建议直接获取实例调用,不要去修改他源码
this.selectComponent('.list-refresh').scrollToTop();
.list-refresh:PullDownRefresh组件的class
image

@lisashare
Copy link

我试了获取 .t-pull-down-refresh t-class="list-refresh" 这两种类名,都获取不到,原来是直接写class类名生效了,感谢,可以用

@anlyyao
Copy link
Collaborator

anlyyao commented Feb 4, 2024

Duplicate of #715

@anlyyao anlyyao marked this as a duplicate of #715 Feb 4, 2024
@github-actions github-actions bot added the duplicate This issue or pull request already exists label Feb 4, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Feb 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants