Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I want change scrollview rolling speed in react native

Now I use interval make it come true, but it is very incoherence. If I can just change the method (scroll) speed, it well be nice.

this.interval = setInterval(()=>{
    if(!_scroll){
        _this.interval && clearInterval(_this.interval);
    }
    if(totalWide+ScreenWidth >= width ){
        _scroll.scrollWithoutAnimationTo();
        totalWide=0;
        i=0;
    }else{
        _scroll.scrollTo({x:eachWide*i,animate:true});
        totalWide = totalWide + eachWide;
        i= i+1;
    }
},250) 
like image 520
Jiajun Avatar asked Dec 24 '22 11:12

Jiajun


1 Answers

use decelerationRate property of ScrollView

<ScrollView decelerationRate={0.5}>

</ScrollView>
like image 118
Nisan Coşkun Avatar answered Apr 02 '23 07:04

Nisan Coşkun