Skip to content
This repository has been archived by the owner on Feb 23, 2023. It is now read-only.

Is it possible to add hash to the gallery when it is opened by API? #1271

Closed
MichaelHefetz opened this issue Mar 10, 2017 · 1 comment
Closed

Comments

@MichaelHefetz
Copy link

MichaelHefetz commented Mar 10, 2017

In the homepage example there is a Customized layout example that adds: #cl-group-{n} to the url.
http://fancyapps.com/fancybox/3/#cl-group-{n}

However the hash is not added if opening gallery by API like this:

$("#test").on('click', function() {
  
  $.fancybox.open([
    {
      src  : 'https://c1.staticflickr.com/9/8148/29324593462_abebaddc38_k.jpg',
      opts : {
        caption : 'First caption'
      }
    },
    {
      src  : 'https://c2.staticflickr.com/6/5499/30972532232_051e1dc57e_h.jpg',
      opts : {
        caption : 'Second caption'
      }
    }
  ], {
    loop : false
  });

});

Therefore clicking back on browser doesn't navigate to the state prior opening the gallery.
This can be very useful on android mobile where we usually pressing back to close popups

Thank you

@fancyapps
Copy link
Owner

fancyapps commented Mar 10, 2017

Hi, The last commit makes it possible to use hash when creating manually.

Simply, pass option "hash" - http://codepen.io/fancyapps/pen/wgZXzz?editors=1010

If value of this option matches id of some element, then click event will be triggered for this element on page load (of course, if it matches page hash).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants