Is there a way to fade in an image based on the percentage scrolled, rather than a set number of pixels? I want my website to be responsive and adjust to all screen resolutions. Or perhaps is there a method to have the image fade in when it enters the field of vision?
Below is the code snippet:
$(document).ready(function(){
$(window).bind("scroll", function() {
if ($(this).scrollTop() > 300) {
$("#bluprintdesign").fadeIn();
} else {
$("#bluprintdesign").stop().fadeOut();
}
Currently, the image fades in at 300px scrolled and fades out as you scroll back up. While this is effective, I would prefer it to be based on percentages for better responsiveness.
Appreciate any help or suggestions!