feat: 轮播图interval支持读取变量 (#4380)

This commit is contained in:
RickCole 2022-05-19 13:32:41 +08:00 committed by GitHub
parent 0601d81774
commit 7a99922bba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,7 +5,7 @@ import Transition, {
EXITING
} from 'react-transition-group/Transition';
import {Renderer, RendererProps} from '../factory';
import {resolveVariable} from '../utils/tpl-builtin';
import {resolveVariableAndFilter} from '../utils/tpl-builtin';
import {
autobind,
createObject,
@ -15,7 +15,7 @@ import {
} from '../utils/helper';
import {Action} from '../types';
import {Icon} from '../components/icons';
import {BaseSchema, SchemaCollection, SchemaName, SchemaTpl} from '../Schema';
import {BaseSchema, SchemaCollection, SchemaName} from '../Schema';
import Html from '../components/Html';
import Image from '../renderers/Image';
import {ScopedContext, IScopedContext} from '../Scoped';
@ -38,7 +38,7 @@ export interface CarouselSchema extends BaseSchema {
/**
*
*/
interval?: number;
interval?: number | string;
/**
*
@ -211,7 +211,13 @@ export class Carousel extends React.Component<CarouselProps, CarouselState> {
this.clearAutoTimeout();
if (this.props.auto) {
this.intervalTimeout = setTimeout(this.autoSlide, this.props.interval);
const interval = this.props.interval;
this.intervalTimeout = setTimeout(
this.autoSlide,
typeof interval === 'string'
? resolveVariableAndFilter(interval, this.props.data) || 5000
: interval
);
}
}