Created
October 29, 2018 11:27
-
-
Save sioniks/e6f475f8454f21e8e2f81c11b88ef0b4 to your computer and use it in GitHub Desktop.
show elem by scroll
This file contains 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
let $win = $(window); | |
let $marker = $('#marker'); | |
let $wrap = $('.wrap'); | |
$win.scroll(function () { | |
if ($win.scrollTop() + $win.height() * 0.8 >= $marker.offset().top && $win.scrollTop() <= ($marker.offset().top + $marker.height() * 0.8)) { | |
$wrap.addClass('full'); | |
} else { | |
$wrap.removeClass('full'); | |
} | |
}); | |
<div class="wrap"> | |
<div class="sec"></div> | |
<div class="sec"></div> | |
<div class="sec"></div> | |
<div class="sec" id="marker"></div> | |
<div class="sec"></div> | |
<div class="sec"></div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment