question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`pswp--zoomed-in` should be added immediately if zooming

See original GitHub issue

Hi there, first I must say again how much I love this library!! Congrats on the new major version 🎉

Today I migrated one of my projects from v4 to v5 and I noticed that the class pswp--zoomed-in is not being added before the zoom-animation finishes. This used to be different in v4, where the class was being added immediately after clicking an image. I rely on this class to hide a custom element that I render as an overlay for my images.

As a side note: While looking through the related code, I noticed this line:

el.classList[isZoomedIn ? 'add' : 'remove']('pswp--zoomed-in');

Is there a reason you are not using classList.toggle here? Seems like the perfect use case 😃 The above could be refactored like this:

el.classList.toggle('pswp--zoomed-in', isZoomedIn);

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
dimsemenovcommented, Oct 31, 2022

The v4 was changing class directly in zoomTo method, while the new one is based on the actual zoom value in API. Since zoomTo uses CSS animations, you can’t reliably get zoom value mid-transition, so it updates when the animation ends.

I like your solution though, should probably be merged, unless we find some issue with it.

Is there a reason you are not using classList.toggle here? Seems like the perfect use case 😃

Think it just was ported from some older code that had different browser support, should be changed as well.

0reactions
hirassocommented, Nov 23, 2022

Sorry, I over-estimated my available time and will not be able to contribute to the code base in the near future. Just thought I would give you a short notice, instead of just ghosting 👻

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Zoom Images in Photoshop + Tips and Tricks - YouTube
Plus I've added lots of great tips and tricks to speed up your ... a new zoom level directly 20:27 - Zooming with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found