fancybox icon indicating copy to clipboard operation
fancybox copied to clipboard

Allow initial state of image to be full size when opened

Open bennyb opened this issue 8 years ago • 16 comments

Currently when you click a thumb that's source image is larger then the browser you can then click this image to zoom in to it's full size.

Is it possible to use this full size to start with so avoiding the extra click.

bennyb avatar Apr 05 '17 11:04 bennyb

I had a similar feature request in #1214 ie, fill-style. So instead of a zoom icon, a hand (pan) icon would be available instead if the image is zoomed as in object-fit: cover and therefore pan-able. Thanks.

GeorgeRT avatar Apr 11 '17 15:04 GeorgeRT

This would help significantly when doing image maps and resizing them. If you use any responsive image map plugin it'll apply them first to fancybox and then rescale them the wrong way when expanding the image. Starting the image full size would mitigate this.

seiyria avatar May 02 '17 23:05 seiyria

I'm also looking for this option. Or at least work around. It's really necessary for mobile devices. I looked for triggering zoom afterLoad or afterShow event but without success.

emre-dogan avatar Jul 15 '17 10:07 emre-dogan

I would also like this feature, or workaround. I need to zoom/pan large images and I'd like to keep the UX consistent with other places where fancybox is used as a typical lightbox. I've tried using scaleToActual in the afterShow event, but the animations get messed up.

Aldlevine avatar Jan 17 '18 21:01 Aldlevine

i manage to do by enabling zoom button on default in main.js then used this code and used anchor class as test

$(document).ready(function(){
$(".test").fancybox({
  openEffect    : 'none',
  closeEffect   : 'none',
  afterShow :function() {
    //$(".fancybox").zoom({on:"click"});
     $('.fancybox-button--zoom').click();
  }
});
});

tasz avatar Feb 20 '18 05:02 tasz

Once this is implemented, a second option would be needed to tell if we want to zoom center or top.

P4KM4N avatar Oct 30 '18 20:10 P4KM4N

I would also like this feature implemented

luchomatic avatar Apr 29 '20 18:04 luchomatic

ping :)

maxmlr avatar May 08 '20 22:05 maxmlr

ping :)

I had originally planned to buy multiple licenses and this is unfortunately a breaking issue. Thus I don’t think this is a proper reaction - as a matter of fact this is a common standard capability for most viewers.

maxmlr avatar May 11 '20 06:05 maxmlr

Hello, everyone!

You see, it was too difficult to include this feature in v3 without a significant rewrite and, as a result, it never landed. It made more sense to focus on complete rewrite (it was needed anyway to drop jQuery and to fulfill other feature requests, too) so that fancybox would become even more flexible and powerful. You can see current progress here - https://fancyapps.com/next/ And I have made a quick test there, too - look for "zoom images to fit viewport on start".

If you are curious, then corresponding code looks like this (for v4):

Fancybox.assign('[data-fancybox="zoomgallery"]', {
  // Move close button to top/right corner
  closeButton: "top",

  // Disable default animations
  Image: {
    showClass: false,
    animateThumbnail: false,
  },

  // Events
  on: {
    done: (fancybox, slide) => {
      const panzoom = slide.Panzoom;

      if (panzoom) {
        // Here, calculate ratio and zoom at top position
        const contentWidth = panzoom.contentDim.width;
        const viewportWidth = panzoom.viewportDim.width;

        panzoom.zoomTo(viewportWidth / contentWidth, { y: 0, friction: 0 });

        // Fade-in using CSS animation
        fancybox.animateCSS(slide.$content, "fadeIn");
      }
    },
  },
});

As you can see, this way you have control over animations, zoom level, position, etc.

fancyapps avatar May 11 '20 14:05 fancyapps

You can see current progress here - https://fancyapps.com/next/ This looks awesome and great you're dropping the need for jQuery.

bennyb avatar May 11 '20 14:05 bennyb

@GeorgeRT Hmm, sorry about that. Everything works fine for me, but https://www.uptrends.com/tools/uptime indeed shows that fancyapps.com is not accessible from some parts in the world. It is planned to move to GithHub pages, I hope that this will eliminate such problems.

fancyapps avatar May 11 '20 16:05 fancyapps

I had removed the comment because I was able to access the URL from my work computer (VPN'd). Thanks for the update! I am using 1.1.1.1/1.0.0.1 as my DNS server.

GeorgeRT avatar May 11 '20 16:05 GeorgeRT

That looks very promising, great work - thank you! Is there any estimate as to when the next version will be production ready?

maxmlr avatar May 11 '20 17:05 maxmlr

@fancyapps could you provide example code for latest version of FancyApps?

mhinesStockDev avatar Mar 09 '22 17:03 mhinesStockDev

@mhinesStockDev The problem with this feature is how to combine it with grouping and swiping. If you would display single images, then it could be done like this - https://fancyapps.com/playground/2gS

fancyapps avatar Mar 22 '22 10:03 fancyapps