mirror of
https://github.com/hanzoai/forum.git
synced 2026-09-30 21:51:19 +00:00
The stacking context fix we use in chat to avoid: https://bugs.webkit.org/show_bug.cgi?id=262287 was causing this weird behavior in chat where the scroll event wouldn't fire when the finger is on text and not an empty area of the scrollable div. This simplified implementation seems to work reliably and avoids the issue.
21 lines
740 B
JavaScript
21 lines
740 B
JavaScript
import { capabilities } from "discourse/services/capabilities";
|
|
|
|
// since -webkit-overflow-scrolling: touch can't be used anymore to disable momentum scrolling
|
|
// we use different hacks to work around this
|
|
// if you change any line in this method, make sure to test on iOS
|
|
export function stackingContextFix(scrollable, callback) {
|
|
callback?.();
|
|
|
|
if (capabilities.isIOS) {
|
|
// stores scroll position otherwise we will lose it
|
|
const currentScroll = scrollable.scrollTop;
|
|
|
|
const display = scrollable.style.display;
|
|
scrollable.style.display = "none"; // forces redraw on the container
|
|
scrollable.offsetHeight; // triggers a reflow
|
|
scrollable.style.display = display;
|
|
|
|
scrollable.scrollTop = currentScroll;
|
|
}
|
|
}
|