mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 06:28:51 +00:00
fix(phone/twitter): Altered transform on ShowMore
I wasn't sure what the comment was referring to, but changed this to a standard top offset, and it fixed a issue with the transform being screwed up between tweets.
This commit is contained in:
1 parent
19e228894d
commit
ef30daeb65
1 file changed
+1
-27
@@ -6,30 +6,8 @@ import { usePhone } from '../../../../os/phone/hooks/usePhone';
|
|||||||
import Nui from '../../../../os/nui-events/utils/Nui';
|
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||||
import ReportButton from '../buttons/ReportButton';
|
import ReportButton from '../buttons/ReportButton';
|
||||||
|
|
||||||
/**
|
|
||||||
* Ok this is some bullshit. Due to either scaling issues or the NUI
|
|
||||||
* overlay being different than the display resolution just letting
|
|
||||||
* material-ui determine what the anchor positioning of the popover
|
|
||||||
* is not reliable and has some error that appears to scale vertically.
|
|
||||||
*
|
|
||||||
* This vertical offset raises the popover positioning implementing the
|
|
||||||
* transformOrigin prop that material-ui's Popover element provides.
|
|
||||||
*
|
|
||||||
* These coefficients are NOT based on any known offsets or calc()
|
|
||||||
* functions. They are empiricallly determined. The actual scaling issue
|
|
||||||
* does NOT appear to be linear, but over the comparatively low height
|
|
||||||
* of the phone compared to the window it produces results that are within
|
|
||||||
* acceptable tolerances from the player's perspective.
|
|
||||||
* @param top - the computed distance from the top of the window to the top
|
|
||||||
* of the anchor element
|
|
||||||
*/
|
|
||||||
function calculateVerticalOffset(top: number): number {
|
|
||||||
return top * 0.2 - 38;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const ShowMore = ({ id, isReported, isMine }) => {
|
export const ShowMore = ({ id, isReported, isMine }) => {
|
||||||
const [anchorEl, setAnchorEl] = useState<Element | null>(null);
|
const [anchorEl, setAnchorEl] = useState<Element | null>(null);
|
||||||
const [verticalOffset, setVerticalOffset] = useState(0);
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { config } = usePhone();
|
const { config } = usePhone();
|
||||||
|
|
||||||
@@ -38,14 +16,10 @@ export const ShowMore = ({ id, isReported, isMine }) => {
|
|||||||
const handleClick = (event: React.MouseEvent) => {
|
const handleClick = (event: React.MouseEvent) => {
|
||||||
const element = event.currentTarget;
|
const element = event.currentTarget;
|
||||||
setAnchorEl(element);
|
setAnchorEl(element);
|
||||||
|
|
||||||
const top = window.pageYOffset + element.getBoundingClientRect().top;
|
|
||||||
setVerticalOffset(calculateVerticalOffset(top));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
setAnchorEl(null);
|
setAnchorEl(null);
|
||||||
setVerticalOffset(0);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDeleteTweet = () => {
|
const handleDeleteTweet = () => {
|
||||||
@@ -72,7 +46,7 @@ export const ShowMore = ({ id, isReported, isMine }) => {
|
|||||||
open={Boolean(anchorEl)}
|
open={Boolean(anchorEl)}
|
||||||
onClose={handleClose}
|
onClose={handleClose}
|
||||||
transformOrigin={{
|
transformOrigin={{
|
||||||
vertical: verticalOffset,
|
vertical: -30,
|
||||||
horizontal: 'left',
|
horizontal: 'left',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in new issue
Block a user