dimsemenov / PhotoSwipe

JavaScript image gallery for mobile and desktop, modular, framework independent
http://photoswipe.com
MIT License
24.18k stars 3.31k forks source link

Open in fullscreen mode #851

Open ghost opened 9 years ago

ghost commented 9 years ago

Is there a current/planed option for this? I'm actually using this:

gallery = ...
gallery.init()
gallery.ui.getFullscreenAPI().enter()

is this a good approach?

Also i'm listening on fullscreenchange event and closing the photoswipe when fullscreen exited:

document.addEventListener App.vendor_prefix + 'fullscreenchange', ->
  return if document.mozFullScreen || document.webkitIsFullScreen # actually in fullscreen mode
  gallery.close()

it works well however a error thrown when exiting by pressing esc key. looks like _listeners is already null here

temporarily fixed like this:

_shout = function(name) {
        if (!_listeners)
            return;
        var listeners = _listeners[name];
...
dimsemenov commented 9 years ago

It's fine method, but ideally – you should at first enter fullscreen and only then init PhotoSwipe. I'd recommend to fork the default UI and exclude default fullscreen feature entirely.

it works well however a error thrown when exiting by pressing esc key.

Make sure that you aren't calling any method on PhotoSwipe that is already destroyed (closed).

rodislav commented 9 years ago

Hi, the issue with _listeners also affects my project, my question is - any time I close (by clicking on close button) photoSwipe - should I init() again ? or create new instance ?

dimsemenov commented 9 years ago

@rodislav, close() destroys PhotoSwipe instance, you can not execute anything after it, PhotoSwipe is in memory only when it's open.

my question is - any time I close (by clicking on close button) photoSwipe - should I init() again ? or create new instance ?

Create new instance.

rodislav commented 9 years ago

ok, got it thanks a lot for help!

COLABORATI commented 8 years ago

could you please add an example how to implement this the right way? I also would like to have a no-thumbnail gallery that starts in fullscreen mode directly when visiting the site. Currently I played with the examples, but when hitting the esc key the page is blank (as there is nothing else). It would be really nice if photoswipe supported a fullscreen gallery by default. Here is a fork of the old photoswipe that shows very well, what I want, but it is, well, based on the old version... would be great to have this in your version! Thanks for your attention! https://github.com/jonathanbell/photoswipe

prabhathAmila commented 8 years ago

hi I want to listen to is the photo full screen or not. but listen function not working. "gallery.listen('requestFullscreen',function(){console.log('requestFullscreen');});" please help

thank you.

ghost commented 7 years ago

I developed a library to allow PhotoSwipe to open in fullscreen mode with support for deep linking to specific gallery images. Here's the code needed to do so, which uses the initPhotoSwipeFromDOM function from the PhotoSwipe docs:

fetchInject([
  '/css/vendor/photoswipe/photoswipe.css',
  '/css/vendor/photoswipe/default-skin/default-skin.css',
  '/js/vendor/photoswipe/photoswipe.min.js',
  '/js/vendor/photoswipe/photoswipe-ui-default.min.js'
]).then(() => {
  initPhotoSwipeFromDOM('[itemtype="http://schema.org/ImageGallery"]')
})

It loads everything in asynchronously in parallel, so you won't need to add any link or script tags directly to your markup to get PhotoSwipe loaded.

pwsp

More info here: https://github.com/jhabdas/fetch-inject#loading-and-handling-composite-libraries

mayagithub87 commented 4 years ago

Hello everyone, the way I solve this problem was like this:

var gallery = new PhotoSwipe($pswp, PhotoSwipeUI_Default, container, options);
gallery.init();
let psAPI = gallery.ui.getFullscreenAPI();
psAPI.enter();
gallery.listen('close', function (name) {
    psAPI.exit();
});

Hope it helps!

Satish-TD commented 4 years ago

Hello everyone, the way I solve this problem was like this:

var gallery = new PhotoSwipe($pswp, PhotoSwipeUI_Default, container, options);
gallery.init();
let psAPI = gallery.ui.getFullscreenAPI();
psAPI.enter();
gallery.listen('close', function (name) {
    psAPI.exit();
});

Hope it helps!

This will not work in mobile