Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix blurry right click menus #2882

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,22 @@ const getStylesFromRect = (options: {
const shouldApplyMobileWidth = isMobileScreen() && disableMobileFullscreenTakeover && !disableApplyingMobileWidth
const marginForMobile = percentOf(10, window.innerWidth)

let xTranslation = shouldApplyMobileWidth ? marginForMobile / 2 : Math.floor(rect.x)
let yTranslation = Math.floor(rect.y)

// There is a bug in Chrome that results in blurry results from translate calls:
//
// https://stackoverflow.com/questions/32034574/font-looks-blurry-after-translate-in-chrome
//
// To work around this issue and ensure the right click menu is always pixel perfect,
// ensure even numbers are used.
xTranslation = Math.floor(xTranslation / 2) * 2
yTranslation = Math.floor(yTranslation / 2) * 2

return {
willChange: 'transform',
'--translate-x': `${shouldApplyMobileWidth ? marginForMobile / 2 : Math.floor(rect.x)}px`,
'--translate-y': `${Math.floor(rect.y)}px`,
'--translate-x': `${xTranslation}px`,
'--translate-y': `${yTranslation}px`,
'--offset': `${options.offset}px`,
transform: 'translate3d(var(--translate-x), var(--translate-y), 0)',
'--transform-origin': getTransformOrigin(options.side, options.align),
Expand Down
Loading