Reactで画面切り替え(ページの遷移はありません)をおこなう際にアニメーションを付与したいと考えています。エラーなどは出ていないのですが、正常に動いておらず困っています。
<開発環境>
React: 16.4.2
Animsition
http://git.blivesta.com/animsition/
下記のソースコードで実行すると、ローディング画面のものがずっと動いているような画面になってしまいます。
ソースコード
scrren-oneからscreen-twoへ「次へ進む」を押した時に遷移できるような仕様にしたいです。
JavaScript
1class App extends Component { 2 constructor(props) { 3 super(props); 4 5 this.state = { 6 screens: { 7 first: true, 8 second: false, 9 }, 10 } 11 12 13 // Screen2へ遷移する場合の処理 14 _next = event => { 15 this.setState({ 16 screens: { 17 first: false, 18 second: true 19 } 20 }); 21 } 22 23 render() { 24 return ( 25 <div className="App"> 26 <section 27 id="screen-one" 28 style={{ display: this.state.screens.first ? 'block' : 'none' }} 29 > 30 31 <a href="#screen-two" className="animsition" onClick={this._next}>次へ進む</a> 32 </section> 33 34 <section 35 id="screen-two" 36 style={{ display: this.state.screens.second ? 'block' : 'none' }} 37 > 38 39 </section> 40 </div> 41 } 42}
JavaScript
1$(document).ready(function() { 2 $(".animsition").animsition({ 3 inClass: 'fade-in-up', 4 outClass: 'fade-out-up', 5 inDuration: 1500, 6 outDuration: 800, 7 linkElement: '.animsition-link', 8 // e.g. linkElement: 'a:not([target="_blank"]):not([href^="#"])' 9 loading: true, 10 loadingParentElement: 'body', //animsition wrapper element 11 loadingClass: 'animsition-loading', 12 loadingInner: '', // e.g '<img src="loading.svg" />' 13 timeout: false, 14 timeoutCountdown: 5000, 15 onLoadEvent: true, 16 browser: [ 'animation-duration', '-webkit-animation-duration'], 17 // "browser" option allows you to disable the "animsition" in case the css property in the array is not supported by your browser. 18 // The default setting is to disable the "animsition" in a browser that does not support "animation-duration". 19 overlay : false, 20 overlayClass : 'animsition-overlay-slide', 21 overlayParentElement : 'body', 22 transition: function(url){ window.location.href = url; } 23 }); 24});
根本的に遷移のやり方がが間違っているのかもしれません。
なにかいいアイデアがあれば教えていただければと思います。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/08/30 10:53