
Originally Posted by
paul3648
I just downloaded and installed the latest 2.1.2 version which looks great, except the images weren't resizing on small screens.
I found this code, meant to go at the end of the jquery.colorbox-min.js file in the template folder.
So just wondering if it's an oversight to leave it out? When I add it the images get resized as expected.
Code:
// Begin Make ColorBox responsive
jQuery.colorbox.settings.maxWidth = '95%';
jQuery.colorbox.settings.maxHeight = '95%';
// ColorBox resize function
var resizeTimer;
function resizeColorBox() {
if (resizeTimer) clearTimeout(resizeTimer);
resizeTimer = setTimeout(function() {
if (jQuery('#cboxOverlay').is(':visible')) {
jQuery.colorbox.resize({width:'90%', height:'90%'});
}
}, 300);
}
// Resize ColorBox when resizing window or changing mobile device orientation
jQuery(window).resize(resizeColorBox);
window.addEventListener("orientationchange", resizeColorBox, false);
// End Make ColorBox responsive
I have taken a look at this as is executed at least from my mobile device. I have one modification to it which I plan to implement by
commenting out the area that provides the problem.
Code:
// Begin Make ColorBox responsive
jQuery.colorbox.settings.maxWidth = '95%';
jQuery.colorbox.settings.maxHeight = '95%';
// ColorBox resize function
var resizeTimer;
function resizeColorBox() {
if (resizeTimer) clearTimeout(resizeTimer);
resizeTimer = setTimeout(function() {
if (jQuery('#cboxOverlay').is(':visible')) {
jQuery.colorbox.resize(/*{width:'90%', height:'90%'}*/);
}
}, 300);
}
// Resize ColorBox when resizing window or changing mobile device orientation
jQuery(window).resize(resizeColorBox);
window.addEventListener("orientationchange", resizeColorBox, false);
// End Make ColorBox responsive
Overall what this does is to execute the resize function of the colorbox code in particular when the device "rotates" so that the image will remain "sized" and the overlay stay in place.
This portion:
Code:
jQuery.colorbox.resize(/*{width:'90%', height:'90%'}*/);
Though, when it calls a designated width and height or a designated innerWidth and innerHeight, there is a problem seen when zooming in/out on a mobile device. With the original "width/height" style, the height of the image when zooming in becomes such that can not see any of the image and makes the feature useless. With "innerWidth/innerHeight" it is possible to zoom in and still see the image (after perhaps a little bit of a screen chase), but when zooming out, the area around the image becomes bigger than original and the text placement shifts, etc... But... Don't do/give anything, and the entire arrangement remains sized right, and that additional "responsiveness" remains present. So, I will be incorporating the above code with the commented out portion so that at least if one wishes to use what seems like was broken, that they could and see associated formatting.
Bookmarks