为了账号安全,请及时绑定邮箱和手机立即绑定

左右轮播时为什么图片会抖动

左右轮播时为什么图片会抖动

慕设计7639819 2016-11-05 17:10:26
<!DOCTYPE html><html>  <head>    <script src="../build/react.js"></script>    <script src="../build/react-dom.js"></script>    <script src="../build/browser.min.js"></script>    <style>    *{      margin:0px;      padding:0px;    }    .box{      width:600px;      height:300px;     overflow:hidden;      margin:0 auto;    }    .nav{        width:1800px;        height:300px;        transition:2s;    }   .nav li{          list-style-type:none;          float:left;          height:300px;           width:600px;   }   .nav li img{    height:300px;    width:600px;    display:block;   }    </style>  </head>  <body>      <div id="Item"></div>    <script type="text/babel">      var Imgd1 =React.createClass({        getInitialState: function () {    return {      marginLeft:0          };  },      componentDidMount: function () {        this.timer = setInterval(function () {          var marginLeft = this.state.marginLeft;          if(marginLeft==-1200){              marginLeft=600;          }          marginLeft -=600;                   this.setState({            marginLeft: marginLeft          });        }.bind(this),2000);      },        render:function(){          return (                       <div className="box">                <ul className="nav" style={this.state}>                  <li><img src="img2.jpg" alt=""/></li>                  <li><img src="img3.jpg" alt=""/></li>                  <li><img src="img4.jpg" alt=""/></li>                </ul>             </div>            )        }      });      ReactDOM.render(          <Imgd1/>,          document.getElementById("Item")      )    </script>      </body></html>
查看完整描述

1 回答

已采纳
?
慕田峪3555374

TA贡献137条经验 获得超18个赞

这是因为轮播图片的速率超过了setinterval的时间间隔

查看完整回答
1 反对 回复 2016-11-05
  • 1 回答
  • 0 关注
  • 4815 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信