Skip to content

Commit 83c06a1

Browse files
committed
fix
1 parent 910ac51 commit 83c06a1

1 file changed

Lines changed: 27 additions & 28 deletions

File tree

Picviewer CE+/Picviewer CE+.user.js

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,6 +1637,7 @@
16371637
'<span class="pv-gallery-head-float-left">'+
16381638
'<span title="图片信息" class="pv-gallery-head-left-img-info">'+
16391639
'<span class="pv-gallery-head-left-img-info-resolution" title="分辨率">0 x 0</span>'+
1640+
'<span class="pv-gallery-head-left-img-info-count" title="图片张数">(1 / 1)</span>'+
16401641
'<span class="pv-gallery-head-left-img-info-scaling" title="缩放比">(100%)</span>'+
16411642
'<span class="pv-gallery-vertical-align-helper"></span>'+
16421643
'<span class="pv-gallery-head-left-img-info-description" title="图片注释"></span>'+
@@ -1839,6 +1840,7 @@
18391840
'head-left-img-info',
18401841
'head-left-img-info-description',
18411842
'head-left-img-info-resolution',
1843+
'head-left-img-info-count',
18421844
'head-left-img-info-scaling',
18431845

18441846
'head-command-close',
@@ -2828,17 +2830,15 @@ padding-left:24px;">'+shareItem.name+'</span>');
28282830
this.slideShow.run('select');
28292831
},
28302832
loadThumb:function(){//读取可视范围里面的缩略图
2831-
28322833
var self=this;
2833-
2834-
var pro=this.isHorizontal ? ['scrollLeft','clientWidth','offsetLeft','offsetWidth'] : ['scrollTop','clientHeight','offsetTop','offsetHeight'];
2835-
var thumbC=this.eleMaps['sidebar-thumbnails-container'];
2834+
var pro=self.isHorizontal ? ['scrollLeft','clientWidth','offsetLeft','offsetWidth'] : ['scrollTop','clientHeight','offsetTop','offsetHeight'];
2835+
var thumbC=self.eleMaps['sidebar-thumbnails-container'];
28362836

28372837
var scrolled=thumbC[pro[0]];
28382838

28392839
var loadStopDis=scrolled + thumbC[pro[1]];
28402840

2841-
var imgSpans=this.selected.parentNode.children;
2841+
var imgSpans=self.selected.parentNode.children;
28422842
var span_i;
28432843
var spanOffset;
28442844
var thumb;
@@ -2866,7 +2866,6 @@ padding-left:24px;">'+shareItem.name+'</span>');
28662866
},
28672867
});
28682868
};
2869-
28702869
},
28712870
selectedIntoView:function(noTransition){
28722871
var thumBC=this.eleMaps['sidebar-thumbnails-container'];
@@ -2997,7 +2996,10 @@ padding-left:24px;">'+shareItem.name+'</span>');
29972996
};
29982997
this.imgNaturalSize=imgNaturalSize;
29992998

3000-
this.eleMaps['head-left-img-info-resolution'].textContent= imgNaturalSize.w + ' x ' + imgNaturalSize.h;
2999+
this.eleMaps['head-left-img-info-resolution'].textContent=imgNaturalSize.w + ' x ' + imgNaturalSize.h;
3000+
var thumbnails=this.eleMaps['sidebar-thumbnails-container'].childNodes,i=0;
3001+
while(thumbnails[i]!=relatedThumb && i<thumbnails.length)i++;
3002+
if(i<thumbnails.length)this.eleMaps['head-left-img-info-count'].textContent="("+(i+1)+" / "+thumbnails.length+")";
30013003
// 加上图片的注释
30023004
var description = decodeURIComponent(dataset(relatedThumb, 'description')),
30033005
defaultLength = prefs.gallery.descriptionLength;
@@ -3116,16 +3118,23 @@ padding-left:24px;">'+shareItem.name+'</span>');
31163118

31173119
_dataCache: {},
31183120
_appendThumbSpans: function(data, index) { // 添加缩略图栏的 spans
3119-
var spanMark = '';
31203121
var iStatisCopy = this.iStatisCopy;
31213122

31223123
if (typeof index == 'undefined' && this.selected) {
31233124
index = Array.prototype.slice.call(this.imgSpans).indexOf(this.selected);
31243125
}
31253126

3127+
var thumbnails = this.eleMaps['sidebar-thumbnails-container'];
3128+
// 如果是新的,则添加,否则重置并添加。
3129+
if (!data){
3130+
thumbnails.innerHTML = "";
3131+
this._dataCache = {};
3132+
}
31263133
(data || this.data).forEach(function(item) {
31273134
iStatisCopy[item.type].count++;
3128-
spanMark += '<span class="pv-gallery-sidebar-thumb-container' +
3135+
var spanMark=document.createElement("span");
3136+
thumbnails.appendChild(spanMark);
3137+
spanMark.outerHTML = '<span class="pv-gallery-sidebar-thumb-container' +
31293138
'" data-type="' + item.type +
31303139
'" data-src="' + item.src +
31313140
(item.xhr ? '" data-xhr="' + encodeURIComponent(JSON.stringify(item.xhr)) : '') +
@@ -3138,17 +3147,6 @@ padding-left:24px;">'+shareItem.name+'</span>');
31383147
'</span>';
31393148
});
31403149

3141-
var thumbnails = this.eleMaps['sidebar-thumbnails-container'];
3142-
3143-
if (data) { // 新的
3144-
thumbnails.innerHTML += spanMark;
3145-
} else {
3146-
thumbnails.innerHTML = spanMark;
3147-
3148-
this._dataCache = {};
3149-
}
3150-
3151-
// 如果是新的,则添加,否则重置并添加。
31523150
var self = this;
31533151
(data || this.data).forEach(function(d) {
31543152
self._dataCache[d.imgSrc] = true;
@@ -3247,6 +3245,7 @@ padding-left:24px;">'+shareItem.name+'</span>');
32473245
//清空dom
32483246
this.eleMaps['sidebar-thumbnails-container'].innerHTML='';
32493247
this.eleMaps['head-left-img-info-resolution'].textContent='0 x 0';
3248+
this.eleMaps['head-left-img-info-count'].textContent='(1 / 1)';
32503249
this.eleMaps['head-left-img-info-scaling'].textContent='(100%)';
32513250
//隐藏滚动条
32523251
this.imgScrollbarV.hide();
@@ -3453,9 +3452,9 @@ padding-left:24px;">'+shareItem.name+'</span>');
34533452
if (result) {
34543453
self.data.push(result);
34553454
self._appendThumbSpans([result]);
3455+
self.loadThumb();
34563456
}
34573457
self._dataCache[this.src] = true;
3458-
self.loadThumb();
34593458
};
34603459
});
34613460
if(prefs.gallery.loadAll)self.nextPage();
@@ -6663,7 +6662,6 @@ background-color:rgba(255, 0, 0, 0.150);\
66636662
sortSearch();
66646663
let from=0;
66656664
let searchFun=function(){
6666-
console.log(self.data.imgSrc);
66676665
searchImgByImg(self.data.imgSrc, null, function(srcs, index){
66686666
let src=srcs.shift();
66696667
if(index==3){
@@ -7668,23 +7666,24 @@ background-image:url("'+ prefs.icons.magnifier +'");\
76687666
// if (!isNaN(imgCS.h)) imgCS.h = Math.round(imgCS.h);
76697667
// if (!isNaN(imgCS.w)) imgCS.w = Math.round(imgCS.w);
76707668

7671-
if (imgAS.h < prefs.gallery.scaleSmallSize && imgAS.w < prefs.gallery.scaleSmallSize) {
7672-
type = 'scaleSmall';
7673-
}else if(!(imgAS.w==imgCS.w && imgAS.h==imgCS.h)){//如果不是两者完全相等,那么被缩放了.
7669+
if(!(imgAS.w==imgCS.w && imgAS.h==imgCS.h)){//如果不是两者完全相等,那么被缩放了.
76747670
if(imgAS.h > prefs.floatBar.minSizeLimit.h || imgAS.w > prefs.floatBar.minSizeLimit.w){//最小限定判断.
76757671
src=imgSrc;
76767672
type='scale';
76777673
// // 图片尺寸相差
76787674
// if (!isNaN(imgCS.h) && (imgAS.h * imgAS.w / (imgCS.h * imgCS.w) * 100 - 100) < prefs.gallery.zoomresized) {
76797675
// type = 'scaleZoomResized'
76807676
// }
7681-
};
7677+
}
76827678
}else{
76837679
if(prefs.floatBar.forceShow.enabled && (imgCS.w>=prefs.floatBar.forceShow.size.w && imgCS.h>=prefs.floatBar.forceShow.size.h)){
76847680
src=imgSrc;
76857681
type='force';
7686-
};
7687-
};
7682+
}
7683+
}
7684+
if (imgAS.h < prefs.gallery.scaleSmallSize && imgAS.w < prefs.gallery.scaleSmallSize) {
7685+
type = 'scaleSmall';
7686+
}
76887687
};
76897688

76907689
if(!src)return;

0 commit comments

Comments
 (0)