add a workaround for a Safari bug that breaks the board sizing

This commit is contained in:
Jesse D. McDonald 2020-04-17 16:02:57 -05:00
parent c791c05d5e
commit baaff7a8c3
1 changed files with 20 additions and 0 deletions

View File

@ -1068,6 +1068,26 @@ $(function (){
gun: gun, gun: gun,
PacoSakoUUID: PacoSakoUUID, PacoSakoUUID: PacoSakoUUID,
}; };
/*
* Safari uses the container's *height* instead of its *width* as
* required by W3C standards for relative margin/padding values.
* This breaks the CSS that should be ensuring a 1:1 aspect ratio.
*/
function fixSafariPadding() {
let elements = $('#cb_container, #cb_board');
for (let element of elements) {
element = $(element);
const width = element.width();
const topPadding = width;
element.css('padding-top', topPadding + 'px');
}
}
if (navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1) {
$(window).on('resize', fixSafariPadding);
fixSafariPadding();
}
}); });
/* vim:set expandtab sw=3 ts=8: */ /* vim:set expandtab sw=3 ts=8: */