mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-02 14:38:46 +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 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 }) => {
|
||||
const [anchorEl, setAnchorEl] = useState<Element | null>(null);
|
||||
const [verticalOffset, setVerticalOffset] = useState(0);
|
||||
const { t } = useTranslation();
|
||||
const { config } = usePhone();
|
||||
|
||||
@@ -38,14 +16,10 @@ export const ShowMore = ({ id, isReported, isMine }) => {
|
||||
const handleClick = (event: React.MouseEvent) => {
|
||||
const element = event.currentTarget;
|
||||
setAnchorEl(element);
|
||||
|
||||
const top = window.pageYOffset + element.getBoundingClientRect().top;
|
||||
setVerticalOffset(calculateVerticalOffset(top));
|
||||
};
|
||||
|
||||
const handleClose = () => {
|
||||
setAnchorEl(null);
|
||||
setVerticalOffset(0);
|
||||
};
|
||||
|
||||
const handleDeleteTweet = () => {
|
||||
@@ -72,7 +46,7 @@ export const ShowMore = ({ id, isReported, isMine }) => {
|
||||
open={Boolean(anchorEl)}
|
||||
onClose={handleClose}
|
||||
transformOrigin={{
|
||||
vertical: verticalOffset,
|
||||
vertical: -30,
|
||||
horizontal: 'left',
|
||||
}}
|
||||
>
|
||||
|
||||
Reference in new issue
Block a user