don't show first image upon init #1236

Open
eldyvoon opened this Issue Nov 7, 2016 · 0 comments

Projects

None yet

1 participant

@eldyvoon
eldyvoon commented Nov 7, 2016

I try to inject image with dynamic height and width with below code, and it worked, but gallery.init() trigger the first item, which is not what I want, how to disable that?

gallery.listen('gettingData', function(index, pswpAlbum_Items) {
if (pswpAlbum_Items.w < 1 || pswpAlbum_Items.h < 1) { // unknown size
var img = new Image();
img.onload = function() { // will get size after load
pswpAlbum_Items.w = this.width; // set image width
pswpAlbum_Items.h = this.height; // set image height
gallery.invalidateCurrItems(); // reinit Items
gallery.updateSize(true); // reinit Items
}
img.src = pswpAlbum_Items.src; // let's download image
}
});
gallery.init().close();
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment