This commit is contained in:
oneao committed 2026-10-09 22:05:02 +08:00
1 parent 0be0b0767a
commit 5f28a10d89
852 files changed
+8962 -111755

No files matched your search

@@ -85,9 +85,16 @@ function update() {
horizontal.overflow = scrollWidth - clientWidth > 1
horizontal.size = horizontal.overflow ? Math.max((clientWidth / scrollWidth) * clientWidth, 20) : 0
const hRange = clientWidth - horizontal.size
// RTL 下原生 scrollLeft 的约定是「0 = 行内起始(右端),向左滚动为负」,
// 直接按比例换算会得到负偏移、滑块跑出轨道。RTL 用「离行内起始的距离」换算:
// 起始时滑块贴右端(offset = hRange),滚到末尾回到左端(offset = 0)。
const hMax = scrollWidth - clientWidth
const rtl = getComputedStyle(el).direction === 'rtl'
horizontal.offset =
horizontal.overflow && hRange > 0
? (scrollLeft / (scrollWidth - clientWidth)) * hRange
? rtl
? hRange * (1 - Math.abs(scrollLeft) / hMax)
: (scrollLeft / hMax) * hRange
: 0
}
@@ -293,7 +300,8 @@ defineExpose({
.#{e('scrollbar', 'track-v')} {
top: 0;
right: 0;
/* 竖直轨道贴行内结束边:LTR 在右、RTL 在左(与原生滚动条行为一致) */
inset-inline-end: 0;
width: v('scrollbar-size', 8px);
height: 100%;
}