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

Problem with Multiple Galleries on Same Page #393

Open
sayontan opened this issue Apr 4, 2022 · 0 comments
Open

Problem with Multiple Galleries on Same Page #393

sayontan opened this issue Apr 4, 2022 · 0 comments

Comments

@sayontan
Copy link

sayontan commented Apr 4, 2022

The fix made for jQuery 3.x was this to forcefully add a swipebox class to the calling element, and then to have the selector variable use that class. While this works fine in some cases, in other cases it causes quite a lot of problems.

In my use case, there are multiple types of galleries on the same page, each with different settings. When you are setting the selector to be universally .swipebox, the binding is getting messy, and the settings of one gallery tend to overlap with another. E.g. I have different functions for the beforeOpen and afterOpen events based on the selectors, but the one defined last is overriding all the others. This is problematic, since it tends to result in errors if certain conditions that would be met for one selector don't apply to the others.

I believe you might want to consider an alternative to hardcoding the selector to .swipebox. The implementation here lets you define a setting called selector, and then use that setting: https://github.com/mho79/swipebox/blob/master/src/js/jquery.swipebox.js.

I would propose a hybrid - you can add the option for the selector, then, in your plugin.init function, use the option if not null. If null, then use the default .swipebox that you added to all elements. This way, users will not have to change their code, and you will be able to fix the bug too.

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

No branches or pull requests

1 participant