index.jsx 999 字节
Newer Older
A
afc163 已提交
1 2 3 4 5 6
// matchMedia polyfill for
// https://github.com/WickyNilliams/enquire.js/issues/82
if (typeof window !== 'undefined') {
  const matchMediaPolyfill = function matchMediaPolyfill() {
    return {
      matches: false,
A
afc163 已提交
7 8 9
      addListener() {
      },
      removeListener() {
A
afc163 已提交
10 11 12 13 14 15
      },
    };
  };
  window.matchMedia = window.matchMedia || matchMediaPolyfill;
}

S
sorrycc 已提交
16
import Carousel from 'react-slick';
S
sorrycc 已提交
17 18 19
import React from 'react';
import assign from 'object-assign';

A
afc163 已提交
20
const AntCarousel = React.createClass({
S
sorrycc 已提交
21 22 23
  getDefaultProps() {
    return {
      dots: true,
A
afc163 已提交
24
      arrows: false,
S
sorrycc 已提交
25 26 27
    };
  },
  render() {
A
afc163 已提交
28
    let props = assign({}, this.props);
S
sorrycc 已提交
29 30 31

    if (props.effect === 'fade') {
      props.fade = true;
32
      props.draggable = false;
S
sorrycc 已提交
33 34
    }

A
afc163 已提交
35
    let className = 'ant-carousel';
S
sorrycc 已提交
36
    if (props.vertical) {
37
      className = `${className} ant-carousel-vertical`;
S
sorrycc 已提交
38 39 40 41 42 43 44 45 46 47 48
    }

    return (
      <div className={className}>
        <Carousel {...props} />
      </div>
    );
  }
});

export default AntCarousel;