1
0
mirror of https://github.com/zedeus/nitter.git synced 2026-04-15 18:22:11 -04:00

Fix mobile gallery and grid, add size preference

Fixes #1379
This commit is contained in:
Zed
2026-03-21 11:28:57 +01:00
parent b6ccea0c7a
commit fea6f59005
7 changed files with 51 additions and 40 deletions

View File

@@ -27,6 +27,13 @@ const GAP = 10;
class Masonry {
constructor(container) {
this.container = container;
const colSizes = {
small: w => Math.max(130, w * 0.11),
medium: w => Math.max(190, Math.min(350, w * 0.22)),
large: w => Math.max(350, Math.min(480, w * 0.22)),
};
const size = container.dataset.colSize || "medium";
this._targetWidth = colSizes[size] || colSizes.medium;
this.colHeights = [];
this.colCounts = [];
this.colCount = 0;
@@ -90,8 +97,8 @@ class Masonry {
}
_rebuild() {
const n = Math.max(1, Math.floor(this.container.clientWidth / 350));
const w = this.container.clientWidth;
const n = Math.max(1, Math.floor(w / this._targetWidth(w)));
if (n === this.colCount && w === this._lastWidth) return;
const isFirst = this.colCount === 0;