mirror of
https://github.com/liriliri/eruda.git
synced 2026-02-02 09:49:00 +08:00
Dev: Improve view for small images
This commit is contained in:
@@ -386,12 +386,28 @@ export default class Resources extends Tool
|
||||
|
||||
let $imgList = this._$el.find('.eruda-image-list');
|
||||
|
||||
let itemWidth = ($imgList.offset().width - 20) / 4.0;
|
||||
$imgList.find('li').css('width', itemWidth);
|
||||
let columnWidth = ($imgList.offset().width - 20) / 80,
|
||||
maxItemWidth = columnWidth * 20;
|
||||
|
||||
$imgList.find('li').each(function ()
|
||||
{
|
||||
let $this = $(this),
|
||||
img = $this.find('img').get(0);
|
||||
|
||||
let itemWidth = columnWidth,
|
||||
imgWidth = img.naturalWidth || 0;
|
||||
|
||||
while (imgWidth > itemWidth && itemWidth < maxItemWidth)
|
||||
{
|
||||
itemWidth += columnWidth;
|
||||
}
|
||||
|
||||
$this.css('width', itemWidth);
|
||||
});
|
||||
|
||||
new Masonry($imgList.get(0), {
|
||||
itemSelector: 'li',
|
||||
columnWidth: itemWidth
|
||||
columnWidth
|
||||
});
|
||||
}
|
||||
_renderHtml(html)
|
||||
|
||||
Reference in New Issue
Block a user