mirror of
https://github.com/danog/telegram-tt.git
synced 2025-01-21 21:01:29 +01:00
Message List: Improve scroll notch
This commit is contained in:
parent
bf4ff6355a
commit
81f12ddb2f
@ -49,7 +49,7 @@ const MessageScroll: FC<OwnProps> = ({
|
||||
// eslint-disable-next-line no-null/no-null
|
||||
const fabTriggerRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
const updateFabVisibility = useCallback(() => {
|
||||
const toggleScrollTools = useCallback(() => {
|
||||
if (isFabFrozen) {
|
||||
return;
|
||||
}
|
||||
@ -69,7 +69,7 @@ const MessageScroll: FC<OwnProps> = ({
|
||||
const { offsetHeight, scrollHeight, scrollTop } = containerRef.current!;
|
||||
const scrollBottom = scrollHeight - scrollTop - offsetHeight;
|
||||
const isNearBottom = scrollBottom <= FAB_THRESHOLD;
|
||||
const isAtBottom = scrollBottom === 0 || (IS_SAFARI && scrollBottom === 1);
|
||||
const isAtBottom = scrollBottom <= 0 || (IS_SAFARI && scrollBottom <= 1);
|
||||
|
||||
onFabToggle(firstUnreadId ? !isAtBottom : !isNearBottom);
|
||||
onNotchToggle(!isAtBottom);
|
||||
@ -113,9 +113,7 @@ const MessageScroll: FC<OwnProps> = ({
|
||||
} = useIntersectionObserver({
|
||||
rootRef: containerRef,
|
||||
margin: FAB_THRESHOLD,
|
||||
}, () => {
|
||||
updateFabVisibility();
|
||||
});
|
||||
}, toggleScrollTools);
|
||||
|
||||
useOnIntersect(fabTriggerRef, observeIntersectionForFab);
|
||||
|
||||
@ -123,9 +121,7 @@ const MessageScroll: FC<OwnProps> = ({
|
||||
observe: observeIntersectionForNotch,
|
||||
} = useIntersectionObserver({
|
||||
rootRef: containerRef,
|
||||
}, () => {
|
||||
updateFabVisibility();
|
||||
});
|
||||
}, toggleScrollTools);
|
||||
|
||||
useOnIntersect(fabTriggerRef, observeIntersectionForNotch);
|
||||
|
||||
@ -150,7 +146,7 @@ const MessageScroll: FC<OwnProps> = ({
|
||||
}, [messageIds]);
|
||||
|
||||
// Workaround for stuck FAB when many unread messages
|
||||
useEffect(updateFabVisibility, [firstUnreadId]);
|
||||
useEffect(toggleScrollTools, [firstUnreadId]);
|
||||
|
||||
return (
|
||||
<div className={className} teactFastList>
|
||||
|
@ -265,7 +265,7 @@
|
||||
height: 1px;
|
||||
background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.4) 2%, rgba(255, 255, 255, 0.4) 98%, rgba(255, 255, 255, 0) 100%);
|
||||
opacity: 0;
|
||||
transition: opacity 200ms ease;
|
||||
transition: opacity 150ms ease;
|
||||
|
||||
@media (max-width: 600px) {
|
||||
left: -2%;
|
||||
|
@ -44,7 +44,6 @@ export default function fastSmoothScroll(
|
||||
|
||||
isAnimating = true;
|
||||
fastRaf(() => {
|
||||
dispatchHeavyAnimationEvent(MAX_JS_DURATION);
|
||||
scrollWithJs(container, element, position, margin, forceDuration, forceCurrentContainerHeight);
|
||||
});
|
||||
}
|
||||
@ -99,6 +98,7 @@ function scrollWithJs(
|
||||
);
|
||||
const startAt = Date.now();
|
||||
|
||||
dispatchHeavyAnimationEvent(duration);
|
||||
animateSingle(() => {
|
||||
const t = Math.min((Date.now() - startAt) / duration, 1);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user