I've built a image gallery page using the following plugin found from a codrop article:
http://tympanus.net/Tutorials/ThumbnailGridExpandingPreview/
I've got the gallery working as intended but I would like to add another feature but I'm struggling to figure out and I would really appreciate any help.
Here's a jsfiddle showing a basic version with the open function working:
Using Hash values loaded from external links I would like the page to load and automatically open the preview, depending on the hash value (for example www.page.com#item-2 would open the second item preview).
I was able to set the hash value using:
window.location.hash;
And by using the string replace I was able to add 'loc-' to the hash value and scroll the page to that ID, this worked great but I would like preview section to open as well.
Is there a way to link the hash value to the following function:
function initItemsEvents( $items ) {
$items.on( 'click', 'span.og-close', function() {
hidePreview();
return false;
} ).children( 'a' ).on( 'click', function(e) {
var $item = $( this ).parent();
// check if item already opened
current === $item.index() ? hidePreview() : showPreview( $item );
return false;
} );
}
Meaning if the page loaded with #item-2 hash value it would fire a click event or simulate a click on the second item, opening the preview.
Thanks in advance for any help.
.children( 'a' ).on( 'click', function(e) {part to work?