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.

The next major release and the project status (your feedback needed)

See original GitHub issue

Demo and docs for the new version

Hi all,

I’d like to share an update on the PhotoSwipe development. And I need your feedback.

Code rewrite and quality

I rewrote everything to modern JavaScript, it should now be easier to contribute or extend. Total JS file size is reduced by about 15%. The code is published in v5-beta branch (src/ for source files, dist/ for compiled files).

Skinning

PhotoSwipe no longer requires an external sprite and has only a single CSS file. Default icons are generated via JavaScript and are very small. Minor styling can be done via CSS variables.

I designed the new icons so they’re visible on the dark and light background without having a dark backdrop:

Frame 3icons

A new guide on how to use your own icons →

Initialization

As you probably know, the current PhotoSwipe initialization is quite a mess, I’m trying to fix this problem.

In the new version, you’re no longer required to include HTML structure for the lightbox itself.

The new version is split into two components, the second is loaded only after user initiates opening, so basic initialization looks like this:

<script type="module">
import PhotoSwipeLightbox from '/v5/photoswipe/photoswipe-lightbox.esm.js';
const options = {
  gallerySelector: '.gallery',
  childSelector: 'a',
  pswpModule: '/v5/photoswipe/photoswipe.esm.js',
};
const lightbox = new PhotoSwipeLightbox(options);
lightbox.init();
</script>

More info about what this code does here.

Obviously, such initialization is optional, and you can just include files via script src.

Animations

  • PhotoSwipe now always uses CSS transitions whenever possible to ensure smooth animation.
  • Improved gesture animations algorithm, it now uses spring animations and more accurately matches native scroll views.
  • Animations are now automatically disabled if the user prefers-reduced-motion.

Opening from cropped thumbnail

PhotoSwipe is now able to animate from the cropped thumbnail. Test it →

Animation4

Opening image in a zoomed state

It’s now easier to control the initial zoom level, Test it →.

Reponsive images

You may now define srcset for images inside the lightbox.

PhotoSwipe now automatically generates and updates sizes attribute depending on zoom level.

Features that will likely be removed:

You may now support PhotoSwipe on OpenCollective

I’ve lost motivation and abandoned the project for a year. I’m trying to find a way to prevent this from happening in the future and keep PhotoSwipe free and open-source.

I’ve created an OpenCollective account, consider sponsoring PhotoSwipe development. To give something in return I will provide email support for sponsors, so you may ask any question if you’re having a problem.


If you have a minute, please test demos for v5 Beta on your mobile device, report issues via GitHub, or just email me.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:178
  • Comments:62 (11 by maintainers)

github_iconTop GitHub Comments

8reactions
john-grcommented, May 4, 2021

To be honest the “Native fullscreen button” is one of the pros on photoswipe please try not to remove it

I use full screen option more often then the zoom in button not sure what other people’s opinion on this but this is my use case.

going directly to full screen is great but it is not good for accessibility which is becoming more and more important everyday. instead of directly opening full screen it will be nice to provide option to choose when and if user wants full screen

thanks

6reactions
evenrevencommented, May 2, 2021

This looks extremely promising. I’m refactoring my entire application frontend now (Rails/Sprockets/jquery to Rails/webpack/vanilla-js/Stimulus) and I’m struggling with Photoswipe because of an old and opaque jquery initializer script, and thinking maybe I should just make the jump to v5 to avoid the extra work.

Getting this to work seems to take minimal effort unless you’re doing something crazy. I’m a novice, and I got it to work with Rails with responsive images and captions in fifteen minutes with a working backend. In contrast, getting a barely working refactored v4 setup up and running took me hours and hours, and that wasn’t even with responsive images (not the fault of v4 per se, my old setup was hard to parse). Great work lowering the barrier to entry, a lot of people will appreciate this! (And thanks for writing thorough examples, I never would have got captions to work otherwise.) I will test more the coming days to look for surprising behaviour (or bugs).

One thing, though: Maybe I’m dense, but can I integrate the examples with a bundler like webpack? The main problem is the inclusion of the pswpModule core (and css) via the options as URL and not through, say, an import statement. Using the webpack path obviously doesn’t work, since node_modules isn’t a public path. I’ve put the whole Photoswipe dist folder in my public path for now, but would like to serve it from node_modules if I can (instead of using a separate script tag). If importing the core module and the css is possible, it’s easier to help with testing transpiling as well. If that’s a goal for you, that is!

Read more comments on GitHub >

github_iconTop Results From Across the Web

8 steps to write an effective project status report - Asana
Effective project status reports are the best way to keep your stakeholders aligned and in the loop during your project progress.
Read more >
Project status report email with samples and templates - Flowrite
Great project status updates and reports are essential to project management. Here's how to do it in an email.
Read more >
The secrets to running project status meetings that work! - PMI
Status review meetings are regularly scheduled events to exchange information about the project. On most projects, status review meetings will be held at ......
Read more >
The most important feedback in a project and how to receive ...
The constructive feedback can then serve as a tool to motivate employees and improve their performance. It is about active listening, seeing ...
Read more >
The Four Phases of Project Management
In the planning phase, however, much is still in flux, so you'll revise your objectives later on, as you gather information about what...
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