芝麻web文件管理V1.00
编辑当前文件:/home/freeclou/app.optimyar.com/backend/node_modules/reactstrap/src/UncontrolledCarousel.js
import React, { Component } from 'react'; import PropTypes from 'prop-types'; import Carousel from './Carousel'; import CarouselItem from './CarouselItem'; import CarouselControl from './CarouselControl'; import CarouselIndicators from './CarouselIndicators'; import CarouselCaption from './CarouselCaption'; const propTypes = { items: PropTypes.array.isRequired, indicators: PropTypes.bool, controls: PropTypes.bool, autoPlay: PropTypes.bool, defaultActiveIndex: PropTypes.number, activeIndex: PropTypes.number, next: PropTypes.func, previous: PropTypes.func, goToIndex: PropTypes.func, }; class UncontrolledCarousel extends Component { constructor(props) { super(props); this.animating = false; this.state = { activeIndex: props.defaultActiveIndex || 0 }; this.next = this.next.bind(this); this.previous = this.previous.bind(this); this.goToIndex = this.goToIndex.bind(this); this.onExiting = this.onExiting.bind(this); this.onExited = this.onExited.bind(this); } onExiting() { this.animating = true; } onExited() { this.animating = false; } next() { if (this.animating) return; const nextIndex = this.state.activeIndex === this.props.items.length - 1 ? 0 : this.state.activeIndex + 1; this.setState({ activeIndex: nextIndex }); } previous() { if (this.animating) return; const nextIndex = this.state.activeIndex === 0 ? this.props.items.length - 1 : this.state.activeIndex - 1; this.setState({ activeIndex: nextIndex }); } goToIndex(newIndex) { if (this.animating) return; this.setState({ activeIndex: newIndex }); } render() { const { defaultActiveIndex, autoPlay, indicators, controls, items, goToIndex, ...props } = this.props; const { activeIndex } = this.state; const slides = items.map((item) => { const key = item.key || item.src; return (
); }); return (
{indicators &&
} {slides} {controls &&
} {controls &&
}
); } } UncontrolledCarousel.propTypes = propTypes; UncontrolledCarousel.defaultProps = { controls: true, indicators: true, autoPlay: true, }; export default UncontrolledCarousel;