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

Add option to control zoom animation duration #609

Open
txbsywcq opened this issue Jan 23, 2024 · 9 comments
Open

Add option to control zoom animation duration #609

txbsywcq opened this issue Jan 23, 2024 · 9 comments
Labels
enhancement New feature or request

Comments

@txbsywcq
Copy link

txbsywcq commented Jan 23, 2024

I've disabled all animations in my code except for the zoom in/out animation. Can anyone provide assistance, please?

Fancybox.bind('[data-fancybox]', { showClass: false, hideClass: false, Thumbs: false, contentClick: "iterateZoom", Images: { zoom: false, Panzoom: { friction: 0, mouseMoveFriction: 0, decelFriction: 0, dragFriction: 0, maxScale: 2, }, }, Carousel: { friction: 0, transition: false, Navigation: false, }, });

@fancyapps
Copy link
Owner

Hi,

I copy/pasted your code and ... it disables zoom animation - https://jsfiddle.net/t57qLb89/

@txbsywcq
Copy link
Author

I'm sorry, but if you double-click to zoom the image, there will always be an animation.

@fancyapps
Copy link
Owner

In that case, change click (and/or wheel) event:

Fancybox.bind('[data-fancybox]', {
  contentClick: false,
  wheel : false
});    

https://jsfiddle.net/u8p79mgj/

@txbsywcq
Copy link
Author

I mean to disable the animation when zooming the image.

@fancyapps
Copy link
Owner

fancyapps commented Jan 23, 2024

In that case, you have to create your own click handler, like this:

Fancybox.bind('[data-fancybox]', {
  contentClick: false,
  Images: {
    Panzoom : {
      on: {
        click: (panzoom, event) => {
          event.preventDefault();

          if (panzoom.targetScale > 1) {
            panzoom.zoomTo(1, { friction : 0 });
          } else {
            panzoom.zoomTo(panzoom.maxScale, { event, friction : 0 });
          }
        },
      },
    }
  }
});    

https://jsfiddle.net/gz6wvna9/

Disabling animation is not offered "out of the box" because it ruins the user experience and therefore not recommended. Also, all animations are "reactive", for example, if content moves after the drag, but user quickly zooms in/out using the wheel, then animation smoothly transitions from panning to zooming.

@txbsywcq
Copy link
Author

In Panzoom, the option "friction" is currently valid for rotate, flip, fit, and reset animations. I believe it would be more consistent if this option were also valid for image zoom animation. What are your thoughts on this?

@fancyapps
Copy link
Owner

I'm sorry, but I'm curious - why do you want to ruin the user experience? Or you want to allow the user to reduce motion, in which case you'd probably prefer to disable all animations. Anyway, there is currently no option to adjust the zoom friction.

@txbsywcq
Copy link
Author

I'm developing a Tampermonkey extension, and yes, I simply want to disable all animations. It's just my personal preference. Anyway, thanks for your reply.

@fancyapps fancyapps changed the title How can I disable the zoom animation? Add option to control zoom animation duration Jan 23, 2024
@fancyapps fancyapps added the enhancement New feature or request label Jan 23, 2024
@fancyapps fancyapps reopened this Jan 23, 2024
@fancyapps
Copy link
Owner

OK, I will think about it.

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

No branches or pull requests

2 participants