React native 带ScrollView的自动慢速滚动
我正试图让一个文本在ScrollView中自动滚动,足够慢,以便能够阅读它 我已经尝试了scrollToEnd,但不推荐使用duration选项。 我也尝试过使用scrollTo并慢慢增加y偏移量,但效果不太好。 也许我可以通过模拟用户滚动来实现,但我不知道如何实现React native 带ScrollView的自动慢速滚动,react-native,expo,React Native,Expo,我正试图让一个文本在ScrollView中自动滚动,足够慢,以便能够阅读它 我已经尝试了scrollToEnd,但不推荐使用duration选项。 我也尝试过使用scrollTo并慢慢增加y偏移量,但效果不太好。 也许我可以通过模拟用户滚动来实现,但我不知道如何实现 startStopScrolling() { if (this.state.scrolling == false) { this.setState(state => ({ scrolling: true }
startStopScrolling() {
if (this.state.scrolling == false) {
this.setState(state => ({ scrolling: true }));
let that = setInterval(() => {
if (this.state.scrolling == true) {
this.state.scrollOf = this.state.scrollOf + 1;
this.ref.scrollTo({ x: 0, y: this.state.scrollOf, animated: true });
}
}, 10);
} else {
this.setState(state => ({ scrolling: false }));
this.state.scrollOf = 0;
}
}
{
this.ref=数据;
}}
>
{
这是一个;
}}
>
{this.props.navigation.state.params.text}
我创建了世博快餐工作示例:
这与我所做的几乎相同,正如我对scrollTo所说,它看起来不太好。我在没有设置间隔的情况下更新了演示:
<ScrollView
ref={data => {
this.ref = data;
}}
>
<TouchableOpacity
onPress={() => {
this.startStopScrolling();
}}
>
<Text
style={{
fontSize: 25
}}
>
{this.props.navigation.state.params.text}
</Text>
</TouchableOpacity>
</ScrollView>