現在以下のサイトを参考にして、スクロールに応じて表示することはできています。
https://into-the-program.com/website/scroll-animate-css.php
スクロール連動と別に、ページが表示されてアニメーションをさせる方法はありませんか?
また、
以下がコードです
$(window).on('load scroll', function(){ //animatedのclassを持った要素をセレクタに指定 var elem = $('.animated'); elem.each(function () { //data属性からアニメーション名を取得 var isAnimate = $(this).data('animate'); //animated要素に位置を取得 var elemOffset = $(this).offset().top; //現在のスクロールポジションを取得 var scrollPos = $(window).scrollTop(); //ウィンドウの高さを取得 var wh = $(window).height(); //animated要素がウィンドウ内の中央位置にきたら処理 if(scrollPos > elemOffset - wh + (wh / 2)){ $(this).addClass(isAnimate); } }); });
宜しくお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/07/10 17:26
退会済みユーザー
2019/07/10 23:28
2019/07/11 00:10