Last active
November 14, 2017 05:31
-
-
Save sou5534/734c590bbff69b3c0dc46fce061190f7 to your computer and use it in GitHub Desktop.
可視範囲に入ってたらfadeIn
※要jQuery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.fadeinTp01{ | |
opacity : 0.1; | |
transform : translate(0, 50px); | |
transition : all 500ms; | |
} | |
.fadeinTp01.scrollin { | |
opacity : 1; | |
transform : translate(0, 0); | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="fadeinTp02"> | |
この要素fadeIn | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//itemtext fadein | |
$(function(){ | |
$(window).scroll(function (){ | |
$('.fadeinTp01').each(function(){ | |
var elemPos = $(this).offset().top; | |
var scroll = $(window).scrollTop(); | |
var windowHeight = $(window).height(); | |
if (scroll > elemPos - windowHeight + 200){ | |
$(this).addClass('scrollin'); | |
} | |
}); | |
}); | |
}); | |
//複数 | |
$(function(){ | |
$(window).scroll(function (){ | |
$('.fadeinTp01 ,.fadeinTp02').each(function(){ | |
var elemPos = $(this).offset().top; | |
var scroll = $(window).scrollTop(); | |
var windowHeight = $(window).height(); | |
if (scroll > elemPos - windowHeight + 200){ | |
$(this).addClass('scrollin'); | |
} | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment