0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

jQueryに関する自分用メモ

Last updated at Posted at 2023-02-15

・フェードイン

function fadeUpEffect() {
		$('.fadeUpEffect').each(function () {
			var element = $(this).offset().top + 100; //画面上からの距離。+100でmargin-top: 100px;の意味。
			var scroll = $(window).scrollTop();
			var windowHeight = $(window).height();
			if (scroll >= element - windowHeight) {
				$(this).addClass('fadeUp');
			}
		});
  }
  $(window).scroll(function () {
		fadeUpEffect();
  });

CSS↓↓

.fadeUpEffect {
  opacity: 0;   //該当する要素を透明にしとく。
}

.fadeUp {
  opacity: 0;
  animation-name: fadeUp;
  animation-duration: 0.8s;
  animation-fill-mode: forwards;
}
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(40px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?