Manuel-Remus Stanca
asked on
How to hide pics in jquery filterable gallery?
Hi
I have combined two scripts for a gallery. When the user clicks on a button, the images from that group are shown. When the user clicks on an image a lightbox appears and the user can go through all the images instead of the images from that group only. I tried to ass a class named hide-pics to make the rest of the images hidden, but I failed.
The script is below
(function($) {
'use strict';
var $filters = $('.filter [data-filter]'),
$boxes = $('.boxes [data-color]');
$filters.on('click', function(e) {
e.preventDefault();
var $this = $(this);
$filters.removeClass('acti ve');
$this.addClass('active');
var $filterColor = $this.attr('data-filter');
if ($filterColor == 'all') {
$boxes.removeClass('is-ani mated')
.fadeOut().promise().done( function() {
$boxes.addClass('is-animat ed').fadeI n();
});
} else {
$boxes.removeClass('is-ani mated')
.fadeOut().promise().done( function() {
$boxes.filter('[data-color = "' + $filterColor + '"]')
.addClass('is-animated').f adeIn();
});
}
});
})(jQuery);
The gallery is here (Arată tot button means Show all)
http://europrietenia.ro/actiuni-de-ecologizare.html
Thx
I have combined two scripts for a gallery. When the user clicks on a button, the images from that group are shown. When the user clicks on an image a lightbox appears and the user can go through all the images instead of the images from that group only. I tried to ass a class named hide-pics to make the rest of the images hidden, but I failed.
The script is below
(function($) {
'use strict';
var $filters = $('.filter [data-filter]'),
$boxes = $('.boxes [data-color]');
$filters.on('click', function(e) {
e.preventDefault();
var $this = $(this);
$filters.removeClass('acti
$this.addClass('active');
var $filterColor = $this.attr('data-filter');
if ($filterColor == 'all') {
$boxes.removeClass('is-ani
.fadeOut().promise().done(
$boxes.addClass('is-animat
});
} else {
$boxes.removeClass('is-ani
.fadeOut().promise().done(
$boxes.filter('[data-color
.addClass('is-animated').f
});
}
});
})(jQuery);
The gallery is here (Arată tot button means Show all)
http://europrietenia.ro/actiuni-de-ecologizare.html
Thx
use detach instead hiding : https://api.jquery.com/detach/
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.