Skip to content

Commit c453770

Browse files
committed
fix: 修复 NoticeBar 的 animation 属性问题 close #1005
1 parent 4950a3a commit c453770

File tree

1 file changed

+23
-21
lines changed
  • packages/taro-ui/src/components/noticebar

1 file changed

+23
-21
lines changed

packages/taro-ui/src/components/noticebar/index.tsx

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -114,42 +114,48 @@ export default class AtNoticebar extends React.Component<
114114
}
115115

116116
public render(): JSX.Element | boolean {
117-
const { single, icon, marquee, customStyle } = this.props
117+
const {
118+
single,
119+
icon,
120+
marquee,
121+
customStyle,
122+
className,
123+
moreText = '查看详情'
124+
} = this.props
118125
let { showMore, close } = this.props
119-
const { dura } = this.state
126+
const {
127+
dura,
128+
show,
129+
animElemId,
130+
animationData,
131+
isWEAPP,
132+
isALIPAY
133+
} = this.state
120134
const rootClassName = ['at-noticebar']
121-
let _moreText = this.props.moreText
122135

123136
if (!single) showMore = false
124137

125-
if (!_moreText) _moreText = '查看详情'
126-
127138
const style = {}
128139
const innerClassName = ['at-noticebar__content-inner']
129140
if (marquee) {
130141
close = false
131142
style['animation-duration'] = `${dura}s`
132-
innerClassName.push(this.state.animElemId)
143+
innerClassName.push(animElemId)
133144
}
134145

135146
const classObject = {
136147
'at-noticebar--marquee': marquee,
137-
'at-noticebar--weapp':
138-
marquee && (this.state.isWEAPP || this.state.isALIPAY),
148+
'at-noticebar--weapp': marquee && (isWEAPP || isALIPAY),
139149
'at-noticebar--single': !marquee && single
140150
}
141151

142152
const iconClass = ['at-icon']
143153
if (icon) iconClass.push(`at-icon-${icon}`)
144154

145155
return (
146-
this.state.show && (
156+
show && (
147157
<View
148-
className={classNames(
149-
rootClassName,
150-
classObject,
151-
this.props.className
152-
)}
158+
className={classNames(rootClassName, classObject, className)}
153159
style={customStyle}
154160
>
155161
{close && (
@@ -169,12 +175,8 @@ export default class AtNoticebar extends React.Component<
169175
)}
170176
<View className='at-noticebar__content-text'>
171177
<View
172-
id={this.state.animElemId}
173-
animation={{
174-
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
175-
// @ts-ignore
176-
actions: this.state.animationData
177-
}}
178+
id={animElemId}
179+
animation={animationData}
178180
className={classNames(innerClassName)}
179181
style={style}
180182
>
@@ -187,7 +189,7 @@ export default class AtNoticebar extends React.Component<
187189
className='at-noticebar__more'
188190
onClick={this.onGotoMore.bind(this)}
189191
>
190-
<Text className='text'>{_moreText}</Text>
192+
<Text className='text'>{moreText}</Text>
191193
<View className='at-noticebar__more-icon'>
192194
<Text className='at-icon at-icon-chevron-right'></Text>
193195
</View>

0 commit comments

Comments
 (0)