React VR kullanarak bir VR uygulaması yazıyorum ve kullanıcıya o düğmeyi ne kadar süre izlemesi gerektiğini göstermek için (veya bir şeyler) ilerleme çubuğuyla bakış düğmelerini yapıyorum. Bunu nasıl yapabilirim?React VR kullanarak bakış düğmelerini nasıl oluşturabilirim?
constructor(props) {
super(props);
this.state = {
watchTime: 3,
progress: 0,
watching: true
};
}
render() {
return (
<VrButton onEnter={() => this.animateProgress() }
onExit={() => this.stopProgress() }
onClick={()=> this.click() }></VrButton>
);
}
animateProgress() {
this.setState({watching: true});
while (this.state.watchTime >== this.state.progress && this.state.watching === true) {
// after a timeout of one second add 1 to `this.state.progress`
}
this.click();
}
stopProgress() {
this.setState({
progress: 0,
watching: false
});
}
click() {
// Handels the click event
}
Bunu yapmak için daha kolay bir yolu var mı:
ben (bu kodun içindeki bazı böcek en vardır olabilir) bu pseudocode kullanmayı düşünüyorum?