colorbox
colorbox copied to clipboard
Width and height doesn't support vw or vh units
This snippet creates a colorbox of max width and height 90px instead of 90vw and 90vh.
$(".gallery a").colorbox({
maxWidth: "90vw",
maxHeight: "90vh"
});
I came out here from Google myself...
Solution (quick 'n' dirt hack):
Find in jquery.colorbox.js
function setSize(size, dimension) {
return Math.round((/%/.test(size) ? ((dimension === 'x' ? $window.width() : winheight()) / 100) : 1) * parseInt(size, 10));
}
replace by:
function setSize(size, dimension) {
return Math.round((/%/.test(size) ? ((dimension === 'x' ? $window.width() : winheight()) / 100) : 1) * parseInt(size, 10)) *
Math.round((/vw/.test(size) ? (document.documentElement.clientWidth / 100) : 1)) *
Math.round((/vh/.test(size) ? (document.documentElement.clienHeight / 100) : 1));
}
(vw/vh calculation from https://stackoverflow.com/a/28295133/151150 )