Scroll Down Button: Fixes for open embedded message
This commit is contained in:
parent
974b66e1f5
commit
e39a63aa73
@ -7,7 +7,7 @@
|
|||||||
opacity: 0;
|
opacity: 0;
|
||||||
transform: translateY(4.5rem);
|
transform: translateY(4.5rem);
|
||||||
transition: transform .25s cubic-bezier(0.34, 1.56, 0.64, 1), opacity .2s ease;
|
transition: transform .25s cubic-bezier(0.34, 1.56, 0.64, 1), opacity .2s ease;
|
||||||
z-index: 10;
|
z-index: var(--z-scroll-down-button);
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
|
|
||||||
body.animation-level-0 & {
|
body.animation-level-0 & {
|
||||||
|
|||||||
@ -106,20 +106,22 @@ type MessagePositionProperties = {
|
|||||||
isLastInList: boolean;
|
isLastInList: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type OwnProps = {
|
type OwnProps =
|
||||||
message: ApiMessage;
|
{
|
||||||
observeIntersectionForBottom: ObserveFn;
|
message: ApiMessage;
|
||||||
observeIntersectionForMedia: ObserveFn;
|
observeIntersectionForBottom: ObserveFn;
|
||||||
observeIntersectionForAnimatedStickers: ObserveFn;
|
observeIntersectionForMedia: ObserveFn;
|
||||||
album?: IAlbum;
|
observeIntersectionForAnimatedStickers: ObserveFn;
|
||||||
noAvatars?: boolean;
|
album?: IAlbum;
|
||||||
withAvatar?: boolean;
|
noAvatars?: boolean;
|
||||||
withSenderName?: boolean;
|
withAvatar?: boolean;
|
||||||
threadId: number;
|
withSenderName?: boolean;
|
||||||
messageListType: MessageListType;
|
threadId: number;
|
||||||
noComments: boolean;
|
messageListType: MessageListType;
|
||||||
appearanceOrder: number;
|
noComments: boolean;
|
||||||
} & MessagePositionProperties;
|
appearanceOrder: number;
|
||||||
|
}
|
||||||
|
& MessagePositionProperties;
|
||||||
|
|
||||||
type StateProps = {
|
type StateProps = {
|
||||||
theme: ISettings['theme'];
|
theme: ISettings['theme'];
|
||||||
@ -137,6 +139,7 @@ type StateProps = {
|
|||||||
isFocused?: boolean;
|
isFocused?: boolean;
|
||||||
focusDirection?: FocusDirection;
|
focusDirection?: FocusDirection;
|
||||||
noFocusHighlight?: boolean;
|
noFocusHighlight?: boolean;
|
||||||
|
isResizingContainer?: boolean;
|
||||||
isForwarding?: boolean;
|
isForwarding?: boolean;
|
||||||
isChatWithSelf?: boolean;
|
isChatWithSelf?: boolean;
|
||||||
isChannel?: boolean;
|
isChannel?: boolean;
|
||||||
@ -203,6 +206,7 @@ const Message: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
isFocused,
|
isFocused,
|
||||||
focusDirection,
|
focusDirection,
|
||||||
noFocusHighlight,
|
noFocusHighlight,
|
||||||
|
isResizingContainer,
|
||||||
isForwarding,
|
isForwarding,
|
||||||
isChatWithSelf,
|
isChatWithSelf,
|
||||||
isChannel,
|
isChannel,
|
||||||
@ -338,7 +342,7 @@ const Message: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
const withAppendix = contentClassName.includes('has-appendix');
|
const withAppendix = contentClassName.includes('has-appendix');
|
||||||
|
|
||||||
useEnsureMessage(chatId, hasReply ? message.replyToMessageId : undefined, replyMessage, message.id);
|
useEnsureMessage(chatId, hasReply ? message.replyToMessageId : undefined, replyMessage, message.id);
|
||||||
useFocusMessage(ref, chatId, isFocused, focusDirection, noFocusHighlight);
|
useFocusMessage(ref, chatId, isFocused, focusDirection, noFocusHighlight, isResizingContainer);
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
if (!appendixRef.current) {
|
if (!appendixRef.current) {
|
||||||
return;
|
return;
|
||||||
@ -454,7 +458,9 @@ const Message: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
|
|
||||||
if (IS_ANDROID) {
|
if (IS_ANDROID) {
|
||||||
if (windowSize.getIsKeyboardVisible()) {
|
if (windowSize.getIsKeyboardVisible()) {
|
||||||
setTimeout(() => { onContextMenu(e); }, ANDROID_KEYBOARD_HIDE_DELAY_MS);
|
setTimeout(() => {
|
||||||
|
onContextMenu(e);
|
||||||
|
}, ANDROID_KEYBOARD_HIDE_DELAY_MS);
|
||||||
} else {
|
} else {
|
||||||
onContextMenu(e);
|
onContextMenu(e);
|
||||||
}
|
}
|
||||||
@ -941,7 +947,9 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
: selectIsMessageFocused(global, message)
|
: selectIsMessageFocused(global, message)
|
||||||
);
|
);
|
||||||
|
|
||||||
const { direction: focusDirection, noHighlight: noFocusHighlight } = (isFocused && focusedMessage) || {};
|
const {
|
||||||
|
direction: focusDirection, noHighlight: noFocusHighlight, isResizingContainer,
|
||||||
|
} = (isFocused && focusedMessage) || {};
|
||||||
|
|
||||||
const isForwarding = forwardMessages.messageIds && forwardMessages.messageIds.includes(id);
|
const isForwarding = forwardMessages.messageIds && forwardMessages.messageIds.includes(id);
|
||||||
|
|
||||||
@ -987,7 +995,7 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
shouldLoopStickers: selectShouldLoopStickers(global),
|
shouldLoopStickers: selectShouldLoopStickers(global),
|
||||||
...(isOutgoing && { outgoingStatus: selectOutgoingStatus(global, message, messageListType === 'scheduled') }),
|
...(isOutgoing && { outgoingStatus: selectOutgoingStatus(global, message, messageListType === 'scheduled') }),
|
||||||
...(typeof uploadProgress === 'number' && { uploadProgress }),
|
...(typeof uploadProgress === 'number' && { uploadProgress }),
|
||||||
...(isFocused && { focusDirection, noFocusHighlight }),
|
...(isFocused && { focusDirection, noFocusHighlight, isResizingContainer }),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
(setGlobal, actions): DispatchProps => pick(actions, [
|
(setGlobal, actions): DispatchProps => pick(actions, [
|
||||||
|
|||||||
@ -13,6 +13,7 @@ export default function useFocusMessage(
|
|||||||
isFocused?: boolean,
|
isFocused?: boolean,
|
||||||
focusDirection?: FocusDirection,
|
focusDirection?: FocusDirection,
|
||||||
noFocusHighlight?: boolean,
|
noFocusHighlight?: boolean,
|
||||||
|
isResizingContainer?: boolean,
|
||||||
) {
|
) {
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
if (isFocused && elementRef.current) {
|
if (isFocused && elementRef.current) {
|
||||||
@ -26,7 +27,9 @@ export default function useFocusMessage(
|
|||||||
FOCUS_MARGIN,
|
FOCUS_MARGIN,
|
||||||
focusDirection !== undefined ? RELOCATED_FOCUS_OFFSET : undefined,
|
focusDirection !== undefined ? RELOCATED_FOCUS_OFFSET : undefined,
|
||||||
focusDirection,
|
focusDirection,
|
||||||
|
undefined,
|
||||||
|
isResizingContainer,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}, [elementRef, chatId, isFocused, focusDirection, noFocusHighlight]);
|
}, [elementRef, chatId, isFocused, focusDirection, noFocusHighlight, isResizingContainer]);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -170,6 +170,7 @@ export type GlobalState = {
|
|||||||
messageId?: number;
|
messageId?: number;
|
||||||
direction?: FocusDirection;
|
direction?: FocusDirection;
|
||||||
noHighlight?: boolean;
|
noHighlight?: boolean;
|
||||||
|
isResizingContainer?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
selectedMessages?: {
|
selectedMessages?: {
|
||||||
|
|||||||
@ -71,6 +71,7 @@ addReducer('apiUpdate', (global, actions, update: ApiUpdate) => {
|
|||||||
threadId: currentMessageList.threadId,
|
threadId: currentMessageList.threadId,
|
||||||
messageId: message.id,
|
messageId: message.id,
|
||||||
noHighlight: true,
|
noHighlight: true,
|
||||||
|
isResizingContainer: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -276,7 +276,7 @@ addReducer('focusNextReply', (global, actions) => {
|
|||||||
addReducer('focusMessage', (global, actions, payload) => {
|
addReducer('focusMessage', (global, actions, payload) => {
|
||||||
const {
|
const {
|
||||||
chatId, threadId = MAIN_THREAD_ID, messageListType = 'thread', noHighlight, groupedId, groupedChatId,
|
chatId, threadId = MAIN_THREAD_ID, messageListType = 'thread', noHighlight, groupedId, groupedChatId,
|
||||||
replyMessageId,
|
replyMessageId, isResizingContainer,
|
||||||
} = payload!;
|
} = payload!;
|
||||||
|
|
||||||
let { messageId } = payload!;
|
let { messageId } = payload!;
|
||||||
@ -306,7 +306,7 @@ addReducer('focusMessage', (global, actions, payload) => {
|
|||||||
setGlobal(newGlobal);
|
setGlobal(newGlobal);
|
||||||
}, noHighlight ? FOCUS_NO_HIGHLIGHT_DURATION : FOCUS_DURATION);
|
}, noHighlight ? FOCUS_NO_HIGHLIGHT_DURATION : FOCUS_DURATION);
|
||||||
|
|
||||||
global = updateFocusedMessage(global, chatId, messageId, noHighlight);
|
global = updateFocusedMessage(global, chatId, messageId, noHighlight, isResizingContainer);
|
||||||
global = updateFocusDirection(global, undefined);
|
global = updateFocusDirection(global, undefined);
|
||||||
|
|
||||||
if (replyMessageId) {
|
if (replyMessageId) {
|
||||||
|
|||||||
@ -431,7 +431,7 @@ function updateScheduledMessages(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function updateFocusedMessage(
|
export function updateFocusedMessage(
|
||||||
global: GlobalState, chatId?: number, messageId?: number, noHighlight = false,
|
global: GlobalState, chatId?: number, messageId?: number, noHighlight = false, isResizingContainer = false,
|
||||||
): GlobalState {
|
): GlobalState {
|
||||||
return {
|
return {
|
||||||
...global,
|
...global,
|
||||||
@ -440,6 +440,7 @@ export function updateFocusedMessage(
|
|||||||
chatId,
|
chatId,
|
||||||
messageId,
|
messageId,
|
||||||
noHighlight,
|
noHighlight,
|
||||||
|
isResizingContainer,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -188,6 +188,7 @@ $color-user-8: #faa774;
|
|||||||
--z-menu-backdrop: 20;
|
--z-menu-backdrop: 20;
|
||||||
--z-message-highlighted: 14;
|
--z-message-highlighted: 14;
|
||||||
--z-message-context-menu: 13;
|
--z-message-context-menu: 13;
|
||||||
|
--z-scroll-down-button: 12;
|
||||||
--z-mobile-search: 12;
|
--z-mobile-search: 12;
|
||||||
--z-middle-header: 11;
|
--z-middle-header: 11;
|
||||||
--z-middle-footer: 11;
|
--z-middle-footer: 11;
|
||||||
|
|||||||
@ -20,7 +20,7 @@ export default function fastSmoothScroll(
|
|||||||
maxDistance = FAST_SMOOTH_MAX_DISTANCE,
|
maxDistance = FAST_SMOOTH_MAX_DISTANCE,
|
||||||
forceDirection?: FocusDirection,
|
forceDirection?: FocusDirection,
|
||||||
forceDuration?: number,
|
forceDuration?: number,
|
||||||
forceCurrentContainerHeight?: boolean,
|
forceNormalContainerHeight?: boolean,
|
||||||
) {
|
) {
|
||||||
const scrollFrom = calculateScrollFrom(container, element, maxDistance, forceDirection);
|
const scrollFrom = calculateScrollFrom(container, element, maxDistance, forceDirection);
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ export default function fastSmoothScroll(
|
|||||||
forceDuration = 0;
|
forceDuration = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
scrollWithJs(container, element, scrollFrom, position, margin, forceDuration, forceCurrentContainerHeight);
|
scrollWithJs(container, element, scrollFrom, position, margin, forceDuration, forceNormalContainerHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isAnimatingScroll() {
|
export function isAnimatingScroll() {
|
||||||
@ -73,11 +73,11 @@ function scrollWithJs(
|
|||||||
position: ScrollLogicalPosition | 'centerOrTop',
|
position: ScrollLogicalPosition | 'centerOrTop',
|
||||||
margin = 0,
|
margin = 0,
|
||||||
forceDuration?: number,
|
forceDuration?: number,
|
||||||
forceCurrentContainerHeight?: boolean,
|
forceNormalContainerHeight?: boolean,
|
||||||
) {
|
) {
|
||||||
const { offsetTop: elementTop, offsetHeight: elementHeight } = element;
|
const { offsetTop: elementTop, offsetHeight: elementHeight } = element;
|
||||||
const { scrollTop: currentScrollTop, offsetHeight: containerHeight, scrollHeight } = container;
|
const { scrollTop: currentScrollTop, offsetHeight: containerHeight, scrollHeight } = container;
|
||||||
const targetContainerHeight = !forceCurrentContainerHeight && container.dataset.normalHeight
|
const targetContainerHeight = forceNormalContainerHeight && container.dataset.normalHeight
|
||||||
? Number(container.dataset.normalHeight)
|
? Number(container.dataset.normalHeight)
|
||||||
: containerHeight;
|
: containerHeight;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user