views:

56

answers:

2

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?

A: 

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;
            },
wrburgess
A: 

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;
            },
wrburgess