1

Gallerificプラグインがすでに表示されているのと同じ画像をリロードするのを防ぐことは可能ですか?

たとえば、ユーザーが同じサムネイルを2回クリックすると、ギャラリーの画像が再読み込みされます。Gallerifficは、ユーザーが同じ画像を2回要求しているため、新しい画像が要求されるまでリロードしてはならないと判断できますか?

4

2 に答える 2

3

画像が起動されるたびに追跡する静的変数を追加しました。最初の画像が読み込まれると、「再読み込み防止スクリプト」はスキップされます。

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;
            },
于 2010-06-24T00:48:36.080 に答える
0

ええと、私は自分で答えるのに約70%いますが、唯一の問題は、最初の画像(インデックス0)を無視する必要があることです。そうしないと、ギャラリーが起動しません。

このロジックを挿入しました:

if (index == 0 | index != this.currentImage.index){};   

この関数に:

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;
            },
于 2010-06-23T23:27:52.000 に答える