We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
【问题描述】 创建 scrollView 后使用 ref 赋值,外部调用 scrollTo 方法没效果。 控制台输出 ref.current 有值。
scrollView
ref
scrollTo
ref.current
【期望效果】 可以滑动到指定位置。
【代码】
import { createElement, useRef } from 'rax'; import View from 'rax-view'; import ScrollView from 'rax-scrollview'; export default function Home() { const svRef = useRef(null); return ( <View styel={{ width: '100vw', height: '100vw', position: 'relative' }}> <ScrollView ref={svRef} style={{ width: '100vw', height: '100vh' }} > { new Array(100).fill(0).map((value, index) => { return ( <View key={`line-${index}`} style={{ width: '100%', height: '80rpx' }}> line-{index} </View> ); }) } <View style={{ position: 'absolute', right: 0, bottom: '100rpx', width: '200rpx', height: '80rpx', color: 'white', backgroundColor: 'blue' }} onClick={() => { svRef.current.scrollTo({ x: 0, y: 0 }); }}> To Top </View> </ScrollView> </View> ); }
【复现 demo仓库】 https://github.com/MarshallYang/rax-miniapp-scrollto-bug
The text was updated successfully, but these errors were encountered:
目前测试后支付宝小程序确实存在该问题,设置 scroll-top 无法生效,待进一步排查。
Sorry, something went wrong.
支付宝小程序在 scrollTop 值前后未发生变化的情况下会出现这种问题。目前可行的处理方式是在 y 值上加一个微小变量,例如
svRef.current.scrollTo({ y: 0 + Math.random() * 0.01 });
支付宝小程序在 scrollTop 值前后未发生变化的情况下会出现这种问题。目前可行的处理方式是在 y 值上加一个微小变量,例如 svRef.current.scrollTo({ y: 0 + Math.random() * 0.01 });
好的,多谢
非常感谢,解决了我的问题。
ChrisCindy
No branches or pull requests
【问题描述】
创建
scrollView
后使用ref
赋值,外部调用scrollTo
方法没效果。控制台输出
ref.current
有值。【期望效果】
可以滑动到指定位置。
【代码】
【复现 demo仓库】
https://github.com/MarshallYang/rax-miniapp-scrollto-bug
The text was updated successfully, but these errors were encountered: