Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to detach/destroy gallery for recreation #6

Closed
tinybigideas opened this issue Nov 18, 2013 · 7 comments
Closed

Ability to detach/destroy gallery for recreation #6

tinybigideas opened this issue Nov 18, 2013 · 7 comments

Comments

@tinybigideas
Copy link

First off, great little plugin! I'm using inside a tab system, so I'd love an easy way to destroy and recreate the plugin on demand to rebind a dynamic source when required.

At the moment, it's a little fiddly - although, any help much appreciated!

@akalicki
Copy link
Owner

Thanks for the feedback! I'll definitely look into adding something that makes what you're trying to do a bit easier. Do you have your implementation hosted anywhere I can take a look?

@tinybigideas
Copy link
Author

Hey - thanks, here's how I'm currently doing it:

if ($('.gallery #gallery-image').length) {
    $('.gallery #gallery-image').remove();
    $('.gallery-thumbnails li img').removeClass('selected');
    $('.gallery .gallery-image-holder').append('<div id="gallery-image"></div>');
    $('.gallery #gallery-image').gallery({
        source: '[id=' + tabId.split('#')[1] + '] .gallery-thumbnails li img'
    });
}

I remove, and essentially recreate on a new source every time the tab is changed.

But I'd love a simple:

$('.gallery #gallery-image').gallery('destroy');

or a simple way to dynamically change the source:

$('.gallery #gallery-image').gallery('changeSource', source);

@akalicki
Copy link
Owner

Thanks for the details. I think both of those should be fairly easy to do and I'll try to get to them soon. What functionality should the destroy function have? I'm thinking it would just finish the fade out, remove the selected class, and stop the images from cycling. Does that sound good?

@tinybigideas
Copy link
Author

Fantastic, sounds perfect! Thanks, and awesome work!

@akalicki
Copy link
Owner

v2.5.0 is up and should address some of these requests:

  • adds the ability to change the source while the gallery's going
  • adds the ability to destroy the gallery
  • new events are triggered when options are changed or the gallery is destroyed

You can change the gallery's source using the typical option change method:

$('gallery #gallery-image').gallery('option', 'source', newSource);

and you can destroy the gallery using the public destroy method:

$('gallery #gallery-image').gallery('destroy');

Let me know if this solves your problem! I'll keep the issue open until you verify that it's working as hoped.

@ghost ghost assigned akalicki Nov 25, 2013
@tinybigideas
Copy link
Author

Unfortunately, I've shipped the project I was working on with my work around, so I'm not able to easily test any more. But I'm sure it'll all be great! Next time I'm looking for a gallery, I'm 100% using this again as it was exactly what I needed. Awesome job!

@akalicki
Copy link
Owner

Great, thanks for the feedback - these features should've been included in the initial release so I'm glad you brought them up now. I originally wrote the plugin just for personal use so I'm glad to see that others are finding it helpful as well!

Cheers,
Alex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants