1
Iオブジェクトをアニメーション化するCSS遷移を使用したい:同じ機能で反応してスタイリングを2回設定するにはどうしたらいいですか?
<div style={this.setStyle()}>
setStyle() {
const style = {}
if (this.state.fullScreen) {
style.background = 'white'
style.position = 'absolute'
style.transition = 'top 2s'
style.top = '20px'
}
//here I wish to set style.top = 0
return style
}
Iが最初style.top = 20px
を設定したい(アイテムが既にある場合、これは、その後、DOMをレンダリングし直し、その後トリガするstyle.top = 0
を設定。アニメーションどのようにこれを行うことができます
state declaration:
constructor (props) {
super(props)
this.state = {
active: -1,
fullScreen: false,
fullScreenStyle: {
background: 'transparent',
position: 'static',
top: 'auto'
}
}
this.flky = {}
}
setStyle() {
if (this.state.fullScreen) {
this.setState({
fullScreenStyle.background: 'white,
fullScreenStyle.position: 'absolute'
fullScreenStyle.top: '20px'
})
}
がどのようにスタイルがthis.state.styleに移動されてくる。この中
あなたは一つのことを行うことができますか? – HimmatorssetStateは、現在の状態に状態を設定し、 – Codesingh
が働いてからレンダー機能を呼び出しますか? – Codesingh