fix: emoji display

This commit is contained in:
Tristan Yang
2023-05-06 16:39:31 +08:00
parent 2d0123e204
commit 4d7e9f87b6
4 changed files with 29 additions and 0 deletions
@@ -19,6 +19,13 @@ const ReactionPicker: FC<Props> = ({ mid, hidePicker }) => {
const handleReact = (emoji: string) => { const handleReact = (emoji: string) => {
reactMessage({ mid, action: emoji }); reactMessage({ mid, action: emoji });
hidePicker(); hidePicker();
// scroll in to view
const el = document.querySelector(`[data-msg-mid='${mid}']`);
// console.log("eee", el);
if (el) {
el.scrollIntoViewIfNeeded(false);
}
}; };
return ( return (
<div className="z-[999]"> <div className="z-[999]">
+18
View File
@@ -0,0 +1,18 @@
// scrollIntoViewIfNeeded
const isSupported = "scrollIntoViewIfNeeded" in Element.prototype;
if (!isSupported) {
Element.prototype.scrollIntoViewIfNeeded = function (centerIfNeeded = true) {
const el = this;
new IntersectionObserver(function ([entry]) {
const ratio = entry.intersectionRatio;
if (ratio < 1) {
let place = ratio <= 0 && centerIfNeeded ? "center" : "nearest";
el.scrollIntoView({
block: place,
inline: place
});
}
this.disconnect();
}).observe(this);
};
}
+1
View File
@@ -14,6 +14,7 @@ import ReduxRoutes from "./routes";
import NewVersion from "./common/component/NewVersion"; import NewVersion from "./common/component/NewVersion";
// import i18n (needs to be bundled ;)) // import i18n (needs to be bundled ;))
import './i18n'; import './i18n';
import './common/polyfills';
import { isDarkMode } from './common/utils'; import { isDarkMode } from './common/utils';
const root = ReactDOM.createRoot(document.getElementById("root") as HTMLElement); const root = ReactDOM.createRoot(document.getElementById("root") as HTMLElement);
+3
View File
@@ -42,5 +42,8 @@ export declare global {
interface WindowEventMap { interface WindowEventMap {
beforeinstallprompt: BeforeInstallPromptEvent; beforeinstallprompt: BeforeInstallPromptEvent;
} }
interface Element {
scrollIntoViewIfNeeded?: any;
}
} }
export type ShareScreenTrack = ILocalVideoTrack | [ILocalVideoTrack, ILocalAudioTrack]; export type ShareScreenTrack = ILocalVideoTrack | [ILocalVideoTrack, ILocalAudioTrack];