question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TranslateZ transform causes blurry text

See original GitHub issue

I have noticed that in Chrome, on non-retina displays, text can sometimes be blurry when using a scale transition (on whileTap for instance):

Screenshot 2019-10-11 at 13 54 50

vs

Screenshot 2019-10-11 at 13 54 44

I’ve tracked this down to the translateZ(0px) that is added to the transform automatically.

  • transform: translateY(0px) scale(1.025) translateZ(0px); -> blurryness 👎
  • transform: translateY(0px) scale(1.025) -> no blurryness 👌

Here’s a Sandbox where you can see the problem by tapping one of the items, and also see the solution (Project 3 is with translateZ, Project 4 is without):

https://codesandbox.io/s/framer-motion-blurry-text-issue-ryz76

image

The translateZ is probably added for performance reasons / to force GPU rendering, but in this case, it does not deliver the desired result. I would much rather have sharp text than better performance. Note that also the item’s border seems to be a little less sharp. Is there a way to selectively disable this translateZ behaviour, or otherwise best practices to ensure things are rendered sharply?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

3reactions
mattgperrycommented, Oct 11, 2019

There isn’t one I’m afraid. Once something is hardware accelerated it’s a bitmap uploaded onto the GPU. So when it’s upscaled you start to stretch that bitmap rather than re-rasterise the vectors (like the fonts).

The only way around it is to handle layout yourself, render bigger elements to begin with and work with varying down scales like 0.5 normal and 0.6 hover for instance.

2reactions
mattgperrycommented, Oct 11, 2019

The blurriness is caused by hardware acceleration. You can force a component not to use hardware acceleration by providing a custom transformTemplate prop. https://www.framer.com/api/motion/component/#motionprops.transformtemplate

Read more comments on GitHub >

github_iconTop Results From Across the Web

Blurry text after using CSS transform: scale(); in Chrome
For some reason it caused horribly blurry looking scaling in ... transform: perspective(1px) translateZ(0); backface-visibility: hidden;.
Read more >
[Solved] Transforms cause font-smoothing weirdness in Webkit
Basically, certain JavaScripts seem to cause crazy font smoothing stuff ... but it does cause fonts to be a bit blurry on rotate/transform....
Read more >
Blurry text in Chrome with scaling - CodePen
Layer promotion with `transform` or `will-change` causes blurry text in chrome....
Read more >
Css – Blurry text after using CSS transform: scale(); in Chrome
csscss-animationsgoogle-chrometransformwebkit ... to Google Chrome that causes blurry text after doing a transform: scale() . ... transform: translateZ(0);.
Read more >
A fix for when your elements move up and/or blur during ...
3D transform bug in safari pixellating everything - fine in chrome/FF :( Safari text blurs over background video. Animtation is blurred on ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found