设为首页 加入收藏

TOP

React Native 之ScrollView轮播图实现(四)
2017-10-13 10:49:41 】 浏览:768
Tags:React Native ScrollView 实现
p;     
//求出当前页数       let pageIndex = Math.floor(offsetX / ScreenWidth);       //更改状态机       this.setState({ currentPage: pageIndex });     }          /**3.页面指针实现 */       _renderAllIndicator() {       let indicatorArr = [];       let style;       let imgsArr = ImageData.data;       for (let i = 0; i < imgsArr.length; i++) {         //判断         style = (i==this.state.currentPage)?{color:'orange'}:{color:'white'};         indicatorArr.push(           <Text key={i} style={[{fontSize:30},style]}>            ?           </Text>         );       }       return indicatorArr;     }        /**4.通过定时器实现自动播放轮播图 */       _startTimer(){       let scrollView this.refs.scrollView;       this.timer = setInterval(         ()=>{console.log('开启定时器');           let imageCount = ImageData.data.length;          //4.1 设置圆点          let activePage = 0;          //4.2判断          if(this.state.currentPage>=imageCount+1){            activePage 0;          }else{            activePage this.state.currentPage+1;          }          //4.3 更新状态机          this.setState({currentPage:activePage});          //4.4 让scrollview 滚动起来          let offsetX = activePage * ScreenWidth;        &nb
首页 上一页 1 2 3 4 5 下一页 尾页 4/5/5
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇图片的懒加载问题 下一篇html锚点 点击跳转到页面指定位置

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目