Really fix auto-scroll on iOS

This commit is contained in:
0x1eef 2023-12-04 05:03:35 -03:00
parent 6706f8a4a9
commit a3a9f4abb5
2 changed files with 16 additions and 7 deletions

View file

@ -14,7 +14,6 @@ body .root .content.theme {
ul.body.stream {
scrollbar-gutter: stable;
li.ayah {
padding: 10px 0 10px 0;
span.title {
@ -45,6 +44,17 @@ body .root .content.theme {
}
}
ul.body.stream.stopped {
overflow-y: auto;
}
ul.body.stream.playing {
overflow-y: auto;
&::-webkit-scrollbar {
display: none;
}
}
footer {
.timer {
display: flex;

View file

@ -24,12 +24,11 @@ export function Stream({
t,
}: Props) {
const className = classNames("body", "stream");
const style: React.CSSProperties =
endOfStream || isPaused ? { overflowY: "auto" } : { overflowY: "hidden" };
const playState = endOfStream || isPaused ? "stopped" : "playing";
const ref = useRef<HTMLUListElement>();
const ul = useMemo<JSX.Element>(() => {
return (
<ul lang={locale} className={className} style={style} ref={ref}>
<ul lang={locale} className={classNames(className, playState)} ref={ref}>
{stream.map((ayah: Quran.Ayah) => {
return (
<li key={ayah.id} className="ayah fade">
@ -54,13 +53,13 @@ export function Stream({
})}
</ul>
);
}, [stream.length]);
}, [stream.length, isPaused]);
useEffect(() => {
const el = ref.current;
if (el) {
const top = 1024 + el.scrollHeight + el.scrollTop;
el.scrollBy({ behavior: "smooth", top });
const top = el.scrollHeight;
el.scrollTo({ behavior: "smooth", top });
}
}, [stream.length]);