views:

39

answers:

2

I'm using the Galleria plugin in an AP div that is elastic. Galleria centers and crops itself nicely on page load but doesn't handle resizing so gracefully. If I resize and then reload the page, it looks great, so I'm wondering if there is a way to unload/reload the plugin ONLY on resize?

+1  A: 

Handle the resize event.

SLaks
Well, yes, I know about the resize event... But if I simply fire up the plugin again on resize, it doubles all the images into the existing carousel. I'm wondering if there is a generic way to unload whatever Galleria has loaded, BEFORE restarting.
Isaac Lubow
You could remove the old element from the DOM.
SLaks
+1  A: 

if the galleria plugin has a destroy method, use that. but if not, maybe you could try clearing the HTML to it's state before the plugin was originally loaded: effectively resetting the galleria's parent element to empty. maybe use something like

$(window).resize(
    $('#galleria-parent-element').html('');
    //reload galleria plugin to fresh state
);
jordanstephens