Permalink
Browse files

Sometimes, the dummy image was not scaled and centered properly when …

…using lazyLoadChunked().

This was due to the dimensions of the dummy image not being computed in time (with lazyLoadChunked(...)).
We changed the retry method from "retry once after 2ms" to "Utils.wait{ ..., timeout: 100 }" to retry multiple times
  for 100ms.
  • Loading branch information...
1 parent c0bbcfd commit 05a9f5f35499734f0ae469fe7ea2cf86cbe3740d Nils Knappmeier committed Nov 20, 2013
Showing with 30 additions and 8 deletions.
  1. +17 −0 README.rst
  2. +13 −8 src/galleria.js
View
@@ -20,3 +20,20 @@ Documentation is currently available in `reST
<http://en.wikipedia.org/wiki/ReStructuredText>`_ format in the repository.
You can build local HTML using Sphinx: http://sphinx.pocoo.org/
+
+
+Changes compared to original (aino) version of galleria
+=======================================================
+
+* Fix for "No theme CSS loaded", when galleria is loaded dynamically through JS and AJAX Galleria may be inserted into
+ the dom dynamically (e.g. via JavaScript loaded from an AJAX-Request). In such a case, the theme's script-tag seems
+ not to be immediately present in the DOM when the addTheme-function looks for it. We therefore try multiple times
+ before raising an error.
+
+* Sometimes, the dummy image was not scaled and centered properly when using lazyLoadChunked().
+ This was due to the dimensions of the dummy image not being computed in time (with lazyLoadChunked(...)).
+ We changed the retry method from "retry once after 2ms" to "Utils.wait{ ..., timeout: 100 }" to retry multiple times
+ for 100ms.
+
+
+
View
@@ -5621,6 +5621,7 @@ Galleria.addTheme = function( theme ) {
// else look for the absolute path and load the CSS dynamic
if ( !css ) {
+
$(function() {
// Try to determine the css-path from the theme script.
// In IE8/9, the script-dom-element seems to be not present
@@ -6210,22 +6211,26 @@ Galleria.Picture.prototype = {
// Delay the callback to "fix" the Adblock Bug
// http://code.google.com/p/adblockforchrome/issues/detail?id=3701
if ( ( !this.width || !this.height ) ) {
- window.setTimeout( (function( img ) {
- return function() {
- if ( img.width && img.height ) {
+ (function( img) {
+ Utils.wait({
+ until : function() {
+ return img.width && img.height;
+ },
+ success : function() {
complete.call( img );
- } else {
- // last resort, this should never happen but just in case it does...
+ },
+ error : function() {
if ( !resort ) {
$(new Image()).load( onload ).attr( 'src', img.src );
resort = true;
} else {
Galleria.raise('Could not extract width/height from image: ' + img.src +
'. Traced measures: width:' + img.width + 'px, height: ' + img.height + 'px.');
}
- }
- };
- }( this )), 2);
+ },
+ timeout: 100
+ });
+ }( this ));
} else {
complete.call( this );
}

0 comments on commit 05a9f5f

Please sign in to comment.