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

How to programatically enable zoom effect from clicked image on new Fancybox instance? #374

Closed
twilson90 opened this issue Nov 13, 2022 · 3 comments

Comments

@twilson90
Copy link

twilson90 commented Nov 13, 2022

I start my fancybox like so:

var fb = new Fancybox(
    [
        {src: "https://site.com/image1"},
        {src: "https://site.com/image2"},
        {src: "https://site.com/image3"}
    ], {
        startIndex: index,
    }
);

But I trigger it on clicking an image.
How do I make it do the cool scaling effect on opening from the image that was clicked? I can't find an answer anywhere in the documentation.

@twilson90 twilson90 changed the title How to programatically enable zoom effect from source image on new Fancybox How to programatically enable zoom effect from source image on new Fancybox instance? Nov 13, 2022
@twilson90 twilson90 changed the title How to programatically enable zoom effect from source image on new Fancybox instance? How to programatically enable zoom effect from clicked image on new Fancybox instance? Nov 13, 2022
@fancyapps
Copy link
Owner

Hi,

Use $thumb attribute for the thumbnail images, something like this:

{src: "https://lipsum.app/id/36/1024x768", $thumb : document.querySelector('.imglist img')},

@SamuelGaona
Copy link

SamuelGaona commented Dec 29, 2022

There is an issue, if you select index 2, and you close it, the animation runs fine, it vanish inside the original node that was clicked, but if you move to another slide, and close it, it shrink to the corresponding original node, but it does not fade out. Can you look into it?

Great job with the library, the usage of $thumb should be documented.

@fancyapps
Copy link
Owner

Hi,

It should work better in v5. If you experience issues, please, open new issue.

FYI, It is also possible to start Fancybox like this:

Fancybox.fromNodes(Array.from(document.querySelectorAll('[data-fancybox="gallery"]')), {startIndex : 1});

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

3 participants