topscroll.js 2.25 KB
Newer Older
xuzhenghua committed
1 2
import React, {Component} from 'react';
import {Carousel, WingBlank} from 'antd-mobile';
xuzhenghua committed
3
export default class Topscroll extends Component {
xuzhenghua committed
4 5 6
    state = {
        slideIndex:0
    }
xuzhenghua committed
7 8 9

    render() {
        return (
xuzhenghua committed
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
           <div className='top-scroll'>
               <WingBlank>
                   <Carousel className="space-carousel"
                             frameOverflow="visible"
                             cellSpacing={10}
                             slideWidth={0.8}
                             autoplay
                             infinite
                             dotActiveStyle={{
                                 width: '18px',
                                 height: '8px',
                                 background: '#fff',
                                 borderRadius: '4px',
                             }}
                             afterChange={index => this.setState({ slideIndex: index })}
                   >
                       {this.props.data.map((val, index) => (
                           <a
                               key={val}
                               href="http://www.alipay.com"
                               style={{
                                   display: 'block',
                                   position: 'relative',
                                   top: this.state.slideIndex === index ? -6 : 0,
                                   height: this.state.slideIndex === index ? this.props.actheight : this.props.height,
                               }}
                           >
                               <img
                                   src={val.src}
                                   alt=""
                                   style={{ width: '100%', verticalAlign: 'top', height: '100%' }}
                                   onLoad={() => {
                                       // fire window resize event to change height
                                       window.dispatchEvent(new Event('resize'));
                                       // this.setState({ imgHeight: 'auto' });
                                   }}
                               />
                           </a>
                       ))}
                   </Carousel>
               </WingBlank>
           </div>
xuzhenghua committed
52 53 54 55
        );
    }
}