By default it looks like fancybox takes the items in the gallery in the order they are added in the HTML.
Is there another option that by adding an optional data-
attribute, it will reorder them when they are opened, but when they are displayed in the page (not in the gallery popup), they will remain the same?
The code looks like this:
<a class="fancybox" rel="gallery1" href="http://farm2.staticflickr.com/1617/24108587812_6c9825d0da_b.jpg" title="Morning Godafoss (Brads5)">
<img src="http://farm2.staticflickr.com/1617/24108587812_6c9825d0da_m.jpg" alt="" />
</a>
<a class="fancybox" rel="gallery1" href="http://farm4.staticflickr.com/3691/10185053775_701272da37_b.jpg" title="Vertical - Special Edition! (cedarsphoto)">
<img src="http://farm4.staticflickr.com/3691/10185053775_701272da37_m.jpg" alt="" />
</a>
<a class="fancybox" rel="gallery1" href="http://farm1.staticflickr.com/574/22407305427_69cc6e845f_b.jpg" title="Racing against the Protons (tom.leuzi)">
<img src="http://farm1.staticflickr.com/574/22407305427_69cc6e845f_m.jpg" alt="" />
</a>
<a class="fancybox" rel="gallery1" href="http://farm1.staticflickr.com/291/18653638823_a86b58523c_b.jpg" title="Lupines (Kiddi Einars)">
<img src="http://farm1.staticflickr.com/291/18653638823_a86b58523c_m.jpg" alt="" />
</a>
And the JS:
$(".fancybox").fancybox();
How to keep the same HTML code, but to open them in the popup in the following order: 3, 1, 4, 2 (for example)?
I would like something like this:
<a class="fancybox" rel="gallery1" data-fancybox-order="3" ... >
<a class="fancybox" rel="gallery1" data-fancybox-order="1" ... >
<a class="fancybox" rel="gallery1" data-fancybox-order="4" ... >
<a class="fancybox" rel="gallery1" data-fancybox-order="2" ... >
Then if we open in the popup the second image (data-fancybox-order="1"
), there will be no previous button. But if we click next, it will open the forth image. Then, after clicking next again, it will open the first image and then the third image (data-fancybox-order="4"
). In that moment, the next button will disappear.
What's the cleanest way to do this?