私のReact.js
プロジェクトでは、アニメーション/トランジションを使い始めました。下のGIFで、コンポーネントを閉じると、そのコンポーネントはフェードアウトします。フェードした後、私はonAnimationEnd
を使ってコンポーネントを隠します。スライドアップ反応成分の移行
Message
が消えると、下のコンポーネントがスライドしてしまいます。私は、CSSアニメーション/トランジションやリアクション固有の方法で、これをどのように達成するのか、概念的にはわかりません。
Message.js
import React, {PropTypes, Component} from 'react';
import MessageTypes from '../constants/MessageTypes';
export default class Message extends Component {
constructor(props, context) {
super(props, context);
this.handleClick = this.handleClick.bind(this);
this.onAnimationEnd = this.onAnimationEnd.bind(this);
this.state = {
animate: false,
hide: false
}
}
handleClick(e) {
e.preventDefault();
this.setState({animate: true});
}
onAnimationEnd() {
console.log('fdsfd');
this.setState({hide: true});
}
render() {
return (
<div ref="message" onAnimationEnd={this.onAnimationEnd} className={`card message ${this.state.hide ? 'hide open' : ''} ${this.state.animate ? 'message-transition-fade-out' : ''}`}>
<span className={`icon icon-${this.iconLevel()}`} style={{color: `#${this.iconColor()}`}}></span>
<p>
<strong>{this.props.title}</strong><br />
<span dangerouslySetInnerHTML={{ __html: this.props.message }} />
</p>
<a href="#" onClick={this.handleClick}>
<span className="icon icon-close"></span>
</a>
</div>
);
}
}
Message.scssは
.message {
max-height: 150px;
transition: height 2s ease;
&.open {
height: 0; //define your height or use max-height
}
&-transition {
&-fade-out {
@include animation(0s, .3s, fadeout);
}
}
}
が動作していないようです。あなたの提案に関連するコードを私の質問に追加しました。 – frankgreco
cssが間違っています。 'max-height:150px'にします。 –
アニメーションは必要ありません。擬似コードに従ってください。 –