実現したいこと
トップページのみローディングアニメーションを実装。ページ遷移でトップに戻ってくるたび動いてほしい
発生している問題・分からないこと
Androidのページ遷移時にアニメーションが動作しない。
$(window).on('load', function () {} を $(document).on('turbolinks:load', function () {}に変えるとそもそも動かなくなる。
エラーメッセージ
error
1動かないのでなし……
該当のソースコード
JavaScript
1 $(function () { 2 function end_loader() { 3 $('.loading-animation').addClass('active'); 4 } 5 $(document).on('turbolinks:load', function () { 6 setTimeout(function () { end_loader();}, 2000) 7 }); 8 })
CSS
1 .loading-animation { 2 width: 100dvw; 3 height: 100dvh; 4 background: #007CFF url(/images/opening_sp.png) no-repeat 50% 50% / auto 100%; 5 transition: all 1s; 6 z-index: 150; 7 opacity: 1; 8 position: fixed; 9 top: 0; 10 left: 0; 11 } 12 .loading-animation.active { 13 animation: zoomOut 2s; 14 } 15 16 @keyframes zoomOut { 17 0% { 18 background-size: auto 100%; 19 opacity: 1; 20 z-index: 150; 21 display: block; 22 } 23 99.9%, 24 to { 25 background-size: auto 0%; 26 opacity: 0; 27 z-index: -100; 28 display: none; 29 } 30 }
HTML
1<div class="loading-animation"></div>
試したこと・調べたこと
- teratailやGoogle等で検索した
- ソースコードを自分なりに変更した
- 知人に聞いた
- その他
上記の詳細・結果
$(document).on('turbolinks:load', function () {
console.log('Hello World')
});
そもそもこれが動かない
AddClassがまずいのか?と思ってfadeOut(800)とか、toggleClassにしてもだめ
AndroidのUSBデバッグで確認したところ、activeのClassが付与されない
補足
確認ブラウザはPC、AndroidどちらもChrome最新版
Androidのバージョンは16

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。