-
-
Save cj/5733a6fe3005d40c6955 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('.thumbs').each(function () { | |
$('a', this).each(function () { | |
var $a = $(this); | |
// set ids, will use them later | |
$a.attr({id: $a.attr('href').replace(/[\/\.-]/g, '')}); | |
}); | |
var $thumbs = $(this), | |
$fotorama = $thumbs.clone(); | |
$fotorama | |
.on('fotorama:show', function (e, fotorama) { | |
// pick the active thumb by id | |
$('#' + fotorama.activeFrame.id) | |
.addClass('active') | |
.siblings() | |
.removeClass('active'); | |
}) | |
.addClass('fotorama') | |
.removeClass('thumbs') | |
.insertBefore(this) | |
.fotorama({nav: false, width: '100%', maxHeight: 400, ratio: 3/2}); | |
// get access to the API | |
var fotorama = $fotorama.data('fotorama'); | |
$thumbs.on('click', 'a', function (e) { | |
e.preventDefault(); | |
// show frame by id | |
fotorama.show(this.id); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment