Skip to content

Instantly share code, notes, and snippets.

@sioniks
Created October 29, 2018 11:27
Show Gist options
  • Save sioniks/e6f475f8454f21e8e2f81c11b88ef0b4 to your computer and use it in GitHub Desktop.
Save sioniks/e6f475f8454f21e8e2f81c11b88ef0b4 to your computer and use it in GitHub Desktop.
show elem by scroll
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