audio 支持src取变量值
This commit is contained in:
parent
86d6225ced
commit
2f39ea2148
|
@ -17,6 +17,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.#{$ns}Carousel {
|
.#{$ns}Carousel {
|
||||||
|
min-width: $Carousel-minWidth;
|
||||||
|
height: $Carousel-height;
|
||||||
position: relative;
|
position: relative;
|
||||||
display: block;
|
display: block;
|
||||||
background: $Carousel-bg;
|
background: $Carousel-bg;
|
||||||
|
@ -56,8 +58,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
&-container {
|
&-container {
|
||||||
min-width: $Carousel-minWidth;
|
width: 100%;
|
||||||
height: $Carousel-height;
|
height: 100%;
|
||||||
position: relative;
|
position: relative;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import {Renderer, RendererProps} from '../factory';
|
||||||
import {autobind} from '../utils/helper';
|
import {autobind} from '../utils/helper';
|
||||||
import {volumeIcon, muteIcon, playIcon, pauseIcon} from '../components/icons';
|
import {volumeIcon, muteIcon, playIcon, pauseIcon} from '../components/icons';
|
||||||
import {resolveVariable} from '../utils/tpl-builtin';
|
import {resolveVariable} from '../utils/tpl-builtin';
|
||||||
|
import {filter} from '../utils/tpl';
|
||||||
|
|
||||||
export interface AudioProps extends RendererProps {
|
export interface AudioProps extends RendererProps {
|
||||||
className?: string;
|
className?: string;
|
||||||
|
@ -49,7 +50,7 @@ export class Audio extends React.Component<AudioProps, AudioState> {
|
||||||
};
|
};
|
||||||
|
|
||||||
state: AudioState = {
|
state: AudioState = {
|
||||||
src: this.props.value || this.props.src || resolveVariable(this.props.name, this.props.data) || '',
|
src: this.props.value || (this.props.src ? filter(this.props.src, this.props.data) : '') || resolveVariable(this.props.name, this.props.data) || '',
|
||||||
isReady: false,
|
isReady: false,
|
||||||
muted: false,
|
muted: false,
|
||||||
playing: false,
|
playing: false,
|
||||||
|
@ -82,9 +83,12 @@ export class Audio extends React.Component<AudioProps, AudioState> {
|
||||||
componentWillReceiveProps(nextProps:AudioProps) {
|
componentWillReceiveProps(nextProps:AudioProps) {
|
||||||
const props = this.props;
|
const props = this.props;
|
||||||
|
|
||||||
if (props.value !== nextProps.value || props.src !== nextProps.src) {
|
if (
|
||||||
|
props.value !== nextProps.value ||
|
||||||
|
filter(props.src as string, props.data) !== filter(nextProps.src as string, nextProps.data)
|
||||||
|
) {
|
||||||
this.setState({
|
this.setState({
|
||||||
src: nextProps.value || nextProps.src,
|
src: nextProps.value || filter(nextProps.src as string, nextProps.data),
|
||||||
playing: false
|
playing: false
|
||||||
}, () => {
|
}, () => {
|
||||||
this.audio.load();
|
this.audio.load();
|
||||||
|
|
|
@ -262,7 +262,6 @@ export class Carousel extends React.Component<CarouselProps, CarouselState> {
|
||||||
className={cx('Carousel-container')}
|
className={cx('Carousel-container')}
|
||||||
onMouseEnter={this.handleMouseEnter}
|
onMouseEnter={this.handleMouseEnter}
|
||||||
onMouseLeave={this.handleMouseLeave}
|
onMouseLeave={this.handleMouseLeave}
|
||||||
style={carouselStyles}
|
|
||||||
>
|
>
|
||||||
{options.map((option:any, key:number) => (
|
{options.map((option:any, key:number) => (
|
||||||
<Transition
|
<Transition
|
||||||
|
@ -294,7 +293,7 @@ export class Carousel extends React.Component<CarouselProps, CarouselState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={cx(`Carousel Carousel--${controlsTheme}`, className)}>
|
<div className={cx(`Carousel Carousel--${controlsTheme}`, className)} style={carouselStyles}>
|
||||||
{body ? body : placeholder}
|
{body ? body : placeholder}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue