aino/galleria — Issue #221: Scaling of big image fails in Chrome/Safari when switching to fullscreen
Author: crabjuice
Created: 2011-11-08 17:18:56+00:00
State: open

I experienced scaling fails in Chrome/Safari when switching to fullscreen mode and using a big image ("could not scale image: url to big image"). This happens randomly, but reproducable in about 50% of cases. It also seems to be dependent from the size of the browser's window.

After a bit of tinkering, I found out that when this error happens, $container has no parent element ($($container)parent() => []). This results in $container having no size (width: 0, height: 0)

I suspect, that rescale gets called too early and thus fails. I think that I could work around this problem by wrapping the rescale call in fullscreen.enter into a timer, something along the lines of:

// additional wait timer, webkit is too fast sometimes
Utils.addTimer('rescale_wait', function() {

// init the first rescale and attach callbacks
self.rescale(function() {

Utils.addTimer('fullscreen_enter', function() {
// show the image after 50 ms
Utils.show( self.getActiveImage() );

if (typeof callback === 'function') {
callback.call( self );
}

}, 100);

self.trigger( Galleria.FULLSCREEN_ENTER );
});
}, 20);

It would be nice if you could take a look at it, and if it is a viable workaround apply it to a future version.