when determining navbar colour, add a small delay to make sure it was painted
This commit is contained in:
parent
b76c4fa1b3
commit
a04d8bb1b6
@ -6,16 +6,7 @@ var BeautifulJekyllJS = {
|
||||
numImgs : null,
|
||||
|
||||
init : function() {
|
||||
// Set the navbar-dark/light class based on its background color
|
||||
const rgb = $('.navbar').css("background-color").replace(/[^\d,]/g,'').split(",");
|
||||
const brightness = Math.round(( // http://www.w3.org/TR/AERT#color-contrast
|
||||
parseInt(rgb[0]) * 299 +
|
||||
parseInt(rgb[1]) * 587 +
|
||||
parseInt(rgb[2]) * 114
|
||||
) / 1000);
|
||||
if (brightness <= 125) {
|
||||
$(".navbar").removeClass("navbar-light").addClass("navbar-dark");
|
||||
}
|
||||
setTimeout(BeautifulJekyllJS.initNavbar, 10);
|
||||
|
||||
// Shorten the navbar after scrolling a little bit down
|
||||
$(window).scroll(function() {
|
||||
@ -38,6 +29,19 @@ var BeautifulJekyllJS = {
|
||||
BeautifulJekyllJS.initImgs();
|
||||
},
|
||||
|
||||
initNavbar : function() {
|
||||
// Set the navbar-dark/light class based on its background color
|
||||
const rgb = $('.navbar').css("background-color").replace(/[^\d,]/g,'').split(",");
|
||||
const brightness = Math.round(( // http://www.w3.org/TR/AERT#color-contrast
|
||||
parseInt(rgb[0]) * 299 +
|
||||
parseInt(rgb[1]) * 587 +
|
||||
parseInt(rgb[2]) * 114
|
||||
) / 1000);
|
||||
if (brightness <= 125) {
|
||||
$(".navbar").removeClass("navbar-light").addClass("navbar-dark");
|
||||
}
|
||||
},
|
||||
|
||||
initImgs : function() {
|
||||
// If the page was large images to randomly select from, choose an image
|
||||
if ($("#header-big-imgs").length > 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user