简体   繁体   English

反应js nuka轮播自定义箭头定位

[英]react js nuka carousel custom arrow positioning

Im trying to correctly position custom arrows with the nuka carousel component. 我试图用nuka轮播组件正确定位自定义箭头。 I mixed in the decorators but both of my arrows are side by side, how do i work around this? 我混入了装饰器中,但是我的两个箭头并排,我该如何解决? I want an arrow on the center left, and an arrow center right. 我想要一个箭头在左中心,一个箭头在右中心。

var Decorators = [{
  component: React.createClass({
    render() {
      return (
        <div>
          <i className="fa fa-chevron-circle-left fa-3x"
            onClick={this.props.previousSlide} aria-hidden="true"></i>
          <i className="fa fa-chevron-circle-right fa-3x"
            onClick={this.props.nextSlide} aria-hidden="true"></i>
          </div>
      )
    }
  }),
  position: 'CenterLeft',
  style: {
    padding: 20
  }
}];

here is an image of what i have and what i dont want 这是我所拥有和我不想要的图像

在此处输入图片说明

Decorators takes an array of components. 装饰器采用一系列组件。

var Decorators = [
  {
    component: React.createClass({
      render() {
        return (
          <div>
            <i className="fa fa-chevron-circle-left fa-3x" onClick={this.props.previousSlide} aria-hidden="true"></i>
          </div>
        )
      }
    }),
    position: 'CenterLeft',
    style: {
      padding: 20
    }
  },
  {
    component: React.createClass({
      render() {
        return (
          <div>
            <i className="fa fa-chevron-circle-right fa-3x" onClick={this.props.nextSlide} aria-hidden="true"></i>
          </div>
        )
      }
    }),
    position: 'CenterRight',
    style: {
      padding: 20
    }
  }
];

Added optimization to reduce rendering count (added shouldComponentUpdate) 添加了优化以减少渲染次数 (添加了shouldComponentUpdate)

var Decorators = [
  {
    component: React.createClass({

      shouldComponentUpdate(nextProps, nextState) {
          return this.props.currentSlide !== nextProps.currentSlide; 
      },

      render() {
        return (
          <div>
            <i className="fa fa-chevron-circle-left fa-3x" onClick={this.props.previousSlide} aria-hidden="true"></i>
          </div>
        )
      }
    }),
    position: 'CenterLeft',
    style: {
      padding: 20
    }
  },
  {
    component: React.createClass({

      shouldComponentUpdate(nextProps, nextState) {
          return this.props.currentSlide !== nextProps.currentSlide; 
      },

      render() {
        return (
          <div>
            <i className="fa fa-chevron-circle-right fa-3x" onClick={this.props.nextSlide} aria-hidden="true"></i>
          </div>
        )
      }
    }),
    position: 'CenterRight',
    style: {
      padding: 20
    }
  }
];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM