Reputation: 5005
Is it possible to prevent the Gallerific plugin from reloading the same image that’s already showing?
For instance, if a user clicks on the same thumbnail twice, the gallery image reloads. Can Galleriffic determine that the user is requesting the same image twice and thus should not reload until a new image is requested?
Upvotes: 1
Views: 1498
Reputation: 5005
I just added a static variable to keep track each time an image is fired. If the first image is loaded, my "reload prevention script" is skipped.
gotoImage: function(imageData) {
var index = imageData.index;
if(typeof foo == 'undefined') {
foo = 0;
};
foo++;
if (foo == 1 | index != this.currentImage.index){
if (this.onSlideChange)
this.onSlideChange(this.currentImage.index, index);
this.currentImage = imageData;
this.preloadRelocate(index);
this.refresh();
};
return this;
},
Upvotes: 3
Reputation: 5005
Well, I'm about 70% there to answering it myself, but the only problem is that I have to ignore the first image (at index 0) or it won't start the gallery.
Inserted this bit of logic:
if (index == 0 | index != this.currentImage.index){};
Into this function:
gotoImage: function(imageData) {
var index = imageData.index;
if (index == 0 | index != this.currentImage.index){
if (this.onSlideChange)
this.onSlideChange(this.currentImage.index, index);
this.currentImage = imageData;
this.preloadRelocate(index);
this.refresh();
};
return this;
},
Upvotes: 0