It appears that galleria is being invoked twice in galleria_options.js. It seems that any function added into Drupal.behaviors automatically gets called on page load and when an AJAX call completes. But it looks like the function to call galleria in galleria_options.js that is being assigned to Drupal.behaviors is also testing and loading on regular page load and ajax complete. This causes the list of images to be processed twice. This issue appears as slow load time and oddly overlapping main and thumbnail photos when using the drupal ajax pager to move between pages of images. To resolve this issue I removed the following code from galleria_options.js

  // when the ajax call is complete, load galleria - used when viewing in a lightbox!
  $('body').bind("ajaxComplete", function() {
    $g.galleria(options);
    gal_exdtend();
  });

I'm not sure in what instance this code would be used and not already automatically handled by Drupal.behaviors. I've attached a patch that removes those lines. Let me know if this breaks anything and I can re-roll the patch with a conditional.

CommentFileSizeAuthor
galleria_options-js.patch583 bytesryan.wyse

Comments

vivianspencer’s picture

ajaxComplete fires for each individual ajax call, you could alternatively swap ajaxComplete for ajaxStop

// when the ajax call is complete, load galleria - used when viewing in a lightbox!
$('body').bind("ajaxStop", function() {
  $g.galleria(options);
  gal_exdtend();
});

For more info view the following example: http://www.malsup.com/jquery/ajax/