Skip to content
Merged
Changes from 1 commit
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
Next Next commit
Fix blurry right click menus
  • Loading branch information
DarkArc authored Aug 30, 2024
commit d026342a577e48009baf7fc6b2bfc7ba15705dea
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,24 @@ 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: 'translate(var(--translate-x), var(--translate-y))',
Comment thread
DarkArc marked this conversation as resolved.
Outdated
'--transform-origin': getTransformOrigin(options.side, options.align),
visibility: 'visible',
...(canApplyMaxHeight && {
Expand Down