首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >防止Galleriffic插件两次重新加载同一图像

防止Galleriffic插件两次重新加载同一图像
EN

Stack Overflow用户
提问于 2010-06-24 04:01:59
回答 2查看 1.5K关注 0票数 1

有没有可能阻止Gallerific插件重新加载已经显示的相同图像?

例如,如果用户点击同一缩略图两次,图库图像就会重新加载。Galleriffic是否可以确定用户正在请求同一图像两次,因此在请求新图像之前不应重新加载?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2010-06-24 08:48:36

我只是添加了一个静态变量来跟踪每次触发图像的时间。如果加载了第一个镜像,我的“重载防止脚本”将被跳过。

代码语言:javascript
复制
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;
            },
票数 3
EN

Stack Overflow用户

发布于 2010-06-24 07:27:52

好吧,我自己回答了大约70%,但唯一的问题是我必须忽略第一个图像(在索引0处),否则它不会启动图库。

插入了这段逻辑:

代码语言:javascript
复制
if (index == 0 | index != this.currentImage.index){};   

进入此函数:

代码语言:javascript
复制
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;
            },
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3105075

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档