mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-01 03:28:20 +08:00
commit
390653b3e5
@ -2,7 +2,7 @@ import React from 'react';
|
||||
import Transition, {ENTERED, ENTERING, EXITING} from 'react-transition-group/Transition';
|
||||
import {Renderer, RendererProps} from '../factory';
|
||||
import {resolveVariable} from '../utils/tpl-builtin';
|
||||
import {autobind, createObject, isObject} from '../utils/helper';
|
||||
import {autobind, createObject, isObject, isArrayChilrenModified} from '../utils/helper';
|
||||
import {leftArrowIcon, rightArrowIcon} from '../components/icons';
|
||||
|
||||
const animationStyles: {
|
||||
@ -88,6 +88,16 @@ export class Carousel extends React.Component<CarouselProps, CarouselState> {
|
||||
nextAnimation: ''
|
||||
};
|
||||
|
||||
componentWillReceiveProps(nextProps:CarouselProps) {
|
||||
const currentOptions = this.state.options;
|
||||
const nextOptions = nextProps.value || nextProps.options || resolveVariable(nextProps.name, nextProps.data) || [];
|
||||
if (isArrayChilrenModified(currentOptions, nextOptions)) {
|
||||
this.setState({
|
||||
options: nextOptions
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.prepareAutoSlide();
|
||||
}
|
||||
@ -245,7 +255,7 @@ export class Carousel extends React.Component<CarouselProps, CarouselState> {
|
||||
current,
|
||||
nextAnimation
|
||||
} = this.state;
|
||||
|
||||
|
||||
let body:JSX.Element | null = null;
|
||||
let carouselStyles: {
|
||||
[propName: string]: string;
|
||||
|
Loading…
Reference in New Issue
Block a user