Open benoitongit opened 7 years ago
some idea from the source code:
$gallery.justifiedGallery().on('jg.complete jg.resize', function(e){
controller = this.data('jg.controller');
if( controller.rows === 1 ){
this.justifiedGallery({ lastRow:'nojustify' });
}
});
Hi there,
I'm using @biziclop's code with controller.rows === 0
and it kind of works but the only row is fading in so painfully slow my mac sounds like it's going to take off from the desk...
Could you please point out the conflicting part?
Thank you.
Update: Besides the resource hog it seems that captions don't work.
… did you say Mac?
Apple 1 Infinite Loop Cupertino, CA 95014
That's exactly what I made! Let's fix it:
$gallery.justifiedGallery().on('jg.complete jg.resize', function(e){
controller = this.data('jg.controller');
if( controller.rows === 1 && controller.lastRow !== 'nojustify' ){
this.justifiedGallery({ lastRow:'nojustify' });
}
});
Thanks. Where should I use the snippet? I tried using it in the jQuery plugin section and getting Maximum call stack size exceeded error in console; calling it the from a separate JS file (after justifedGallery.js) gives a $gallery not defined error.
Mmmkay.
Go to here: http://miromannino.github.io/Justified-Gallery/options-and-events/
Maybe resize window, fiddle with options
Open your browser's Console and paste this:
var $gallery = $('#endless-gallery, #liveDemo');
$gallery.justifiedGallery();
var controller = $gallery.data('jg.controller');
var wantedLastRowValue = 'justify'; // or 'nojustify'
function checkIfSingleRowIsJustified(){
if(
// controller.rows === 1 && // uncomment this
controller.settings.lastRow !== wantedLastRowValue
){
$gallery.justifiedGallery({ lastRow: wantedLastRowValue });
}
}
$gallery.justifiedGallery().on('jg.complete jg.resize', checkIfSingleRowIsJustified );
checkIfSingleRowIsJustified();
For those who still have this problem, this is working for me as of today:
var $gallery = $('yourCssSelector');
$gallery.justifiedGallery({ ...yourOptions... }).on('jg.complete jg.resize', function(e){
var $this = jQuery(this);
var controller = $this.data('jg.controller');
if( controller.rows === 0){
$this.justifiedGallery({ lastRow: 'justify' });
}else{
$this.justifiedGallery({ lastRow: 'hide' });
}
});
Hi,
Just wondering if there is a way to show the lastRow if there is only one row? Sometime I only have couple images, they fit in one row but they don't show.
Thanks! Benoit