Problem with Multiple Galleries on Same Page
Opened this issue · 0 comments
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.