add a fade in effect to main while scrolling up cover photo

This commit is contained in:
Mario Vavti 2016-03-02 13:33:18 +01:00
parent 22729da2a2
commit c5d08fd5fd

View File

@ -7,6 +7,7 @@ $(document).ready(function() {
if($('#cover-photo').length && $(window).width() > 767) { if($('#cover-photo').length && $(window).width() > 767) {
$('.navbar-fixed-top').css('position', 'relative'); $('.navbar-fixed-top').css('position', 'relative');
$('main').css('padding-top', 0 + 'px'); $('main').css('padding-top', 0 + 'px');
$('main').css('opacity', 0);
} }
else { else {
$('#cover-photo').remove(); $('#cover-photo').remove();
@ -71,4 +72,8 @@ $(window).scroll(function () {
$('.navbar-fixed-top').css('position', 'fixed'); $('.navbar-fixed-top').css('position', 'fixed');
$('#cover-photo').remove(); $('#cover-photo').remove();
} }
if($('#cover-photo').length) {
$('main').css('opacity', ($(window).scrollTop()/$('#cover-photo').height()).toFixed(1));
}
}); });