fix(thumbnail): replace hack for chrome rendering of wrongly dimensio… #1338
+5
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
General summary
This a quick and dirty replace, of a quick and dirty fix made to properly handle Thumbnails when it comes to render small avatars with unadapted size and ratio.
Origin of the issue
The issue is visible when using the
Thumbnailin squared cover mode, when the image should fill the entirety of a it's placeholder (most often used with 64px an 32px size).When the provided image is not squared and/or there is huge downsize from the original image size, Google Chrome sometimes has troubles displaying the image without pixelisation.
First fix
A first fix was introduced in this PR, that was adding a
overflow-clip-margin: unset;in the component CSS code, forcing Chrome to properly render the image without pixelisation.The idea behind this fix was to force Google Chrome to use a better algorithm when rendering the image, this is done by generating a new layer for the image with the CSS property, and then Chrome will deal with the image with a more advanced algorithms.
Second change
In this PR we've replace the first hack
overflow-clip-margin: unsetwith a new onetranslate: 0 0 0.01pxthat does the same thing, by creating a new layer with the transformation made by translate. This was in introduced to remove a console log warning displayed when using the previous property.The new issue
With the last fix, we've introduced a new issues, with the Thumbnail component. This is rare side effect that depend on the user browser, and screen resolution. But visible, when sometime, the thumbnails is used within a carousel that contains a Image rendered by the Thumbnail component. The next slide image is visible on the carousel current slide.
This is due to the
translateproperty that make the image overflow it's slide.The new fix
In order to fix this side effect, we've implemented a similar change, switching again the CSS property used to try
backface-visibility: hiddenthat is a property that will do the same layer hack, but should not have side effects.Screenshots
StoryBook: https://32a00fd4--5fbfb1d508c0520021560f10.chromatic.com/ (Chromatic build)