fix(cbz): smooth scrollbar/slider dragging — rAF-coalesce scroll handler, idle-debounced prefetch, frame-batched height corrections, PageHeights.setEst converges unseen pages to the first measured page size, page slider seeks instantly while scrubbing (no per-notch smooth-animation restart); restore lost ### Fixed header in changelog
This commit is contained in:
@@ -18,6 +18,21 @@ export class PageHeights {
|
||||
for (let i = from; i < this.n; i++) this.cum[i + 1] = this.cum[i] + (this.actual[i] ?? this.est);
|
||||
}
|
||||
|
||||
get estHeight(): number {
|
||||
return this.est;
|
||||
}
|
||||
|
||||
/** 重估默认页高(同开本漫画量出真实比例后,滚动条几何就不再逐页变了)。
|
||||
* 返回起始偏移 < y 的未量高页数——调用方可按 n×Δest 自行补偿 scrollTop。 */
|
||||
setEst(e: number, y: number): number {
|
||||
if (!Number.isFinite(e) || e <= 0 || e === this.est) return 0;
|
||||
let n = 0;
|
||||
for (let i = 0; i < this.n && this.cum[i] < y; i++) if (this.actual[i] === undefined) n++;
|
||||
this.est = e;
|
||||
this.rebuild(0);
|
||||
return n;
|
||||
}
|
||||
|
||||
/** 返回高度增量(相对旧值)。同值幂等返 0;越界/非法高度忽略。 */
|
||||
set(i: number, h: number): number {
|
||||
if (i < 0 || i >= this.n || !Number.isFinite(h) || h <= 0) return 0;
|
||||
|
||||
Reference in New Issue
Block a user