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

User Options lost when calling baguetteBox.show(index, gallery[0]) #240

Open
alantwentyseven opened this issue Aug 22, 2020 · 0 comments
Open

Comments

@alantwentyseven
Copy link

alantwentyseven commented Aug 22, 2020

I have been opening an image automatically (doing my own "open from URL" implementation) - as per the example, but with my own options (such as an onChange listener, no captions, and fade in animation):

const opts = {
    animation: 'fadeIn',
    noScrollbars: true,
    captions: false,
    onChange: function(id) { console.log("ON CHANGE", id); }
}
const gallery = baguetteBox.run('.gallery', opts);
baguetteBox.show(index, gallery[0]);

However, the gallery doesn't move forward until I move back (this may not be related to user options), there are captions, the animation is the default, and nothing happens onChange.

Having a look at source, plus debugging in Chrome dev tools, I think show(index, gallery) intends to prepareOverlay(gallery, options), but the top-level options is still unset.

The only place options is set is in prepareOverlay(gallery, userOptions) itself and run() only sets that function to be called inside the click handler - ie when you press a preview. Thus, running the gallery and then showing an image programmatically does not utilise the user options.

I guess a fix might be to pass the user options for a second time, into show(), but perhaps there's a cleaner way of storing the options during run() for use both in manual (click) and programmatic (show()) use cases?

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