Created
September 22, 2021 19:10
-
-
Save TeamBug99/cbf6d79fc2a4dd12b77c00c2ff860f55 to your computer and use it in GitHub Desktop.
Opacity on scroll
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
var animation_start_pos = 0, animation_end_pos = 1000; //where you want the animation to stop | |
$(document).scroll(function() { | |
var scroll_pos = $(this).scrollTop(); | |
var percentScrolled = parseFloat(scroll_pos/animation_end_pos); | |
jQuery('.people-opacity').css('opacity', percentScrolled ); | |
}); | |
html // | |
<div class="people-opacity" style="opacity: 0;"></div> | |
css// | |
.people-opacity { | |
background: #fff; | |
left: 0; | |
top: 0; | |
opacity: 0; | |
height: 100%; | |
width: 100%; | |
transition: .3s; | |
position: absolute; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment