mirror of
https://github.com/tulir/gomuks.git
synced 2025-04-20 10:33:41 -05:00
web/timeline/menu: don't allow context menu to overflow to the left
This commit is contained in:
parent
7b7fbce4df
commit
b36b7b4e9d
1 changed files with 7 additions and 1 deletions
|
@ -36,8 +36,14 @@ export const getEncryption = (room: RoomStateStore): boolean =>{
|
||||||
return encryptionEvent?.content?.algorithm === "m.megolm.v1.aes-sha2"
|
return encryptionEvent?.content?.algorithm === "m.megolm.v1.aes-sha2"
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getModalStyleFromMouse(evt: React.MouseEvent, modalHeight: number): CSSProperties {
|
export function getModalStyleFromMouse(
|
||||||
|
evt: React.MouseEvent, modalHeight: number, modalWidth = 10 * 16,
|
||||||
|
): CSSProperties {
|
||||||
const style: CSSProperties = { right: window.innerWidth - evt.clientX }
|
const style: CSSProperties = { right: window.innerWidth - evt.clientX }
|
||||||
|
if (evt.clientX - modalWidth < 4) {
|
||||||
|
delete style.right
|
||||||
|
style.left = "4px"
|
||||||
|
}
|
||||||
if (evt.clientY + modalHeight > window.innerHeight) {
|
if (evt.clientY + modalHeight > window.innerHeight) {
|
||||||
style.bottom = window.innerHeight - evt.clientY
|
style.bottom = window.innerHeight - evt.clientY
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue