需求
圖片點擊后,寬度滿屏
問題
viewer.js 在預(yù)覽圖片時,默認(rèn)是0.9的倍數(shù)
修改viewer.js
initImage: function initImage(done) {
...
sizingImage = getImageNaturalSizes(image, function (naturalWidth, naturalHeight) {
var aspectRatio = naturalWidth / naturalHeight;
var width = viewerWidth;
var height = viewerHeight;
_this2.imageInitializing = false;
if (viewerHeight * aspectRatio > viewerWidth) {
height = viewerWidth / aspectRatio;
} else {
width = viewerHeight * aspectRatio;
}
width = Math.min(width * 0.9, naturalWidth); //這里的0.9 改為1 即可
height = Math.min(height * 0.9, naturalHeight); //這里的0.9 改為1 即可