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

[gatsby-image] Transparent PNGs always fade-in #10937

Closed
tylerhunt opened this issue Jan 9, 2019 · 4 comments · May be fixed by MaxMood96/gatsby#504
Closed

[gatsby-image] Transparent PNGs always fade-in #10937

tylerhunt opened this issue Jan 9, 2019 · 4 comments · May be fixed by MaxMood96/gatsby#504
Labels
type: question or discussion Issue discussing or asking a question about Gatsby

Comments

@tylerhunt
Copy link

tylerhunt commented Jan 9, 2019

Description

When using a PNG with a transparent background, there's a blurred fade-in effect even with fadeIn set to false.

Steps to reproduce

Add a PNG with an alpha channel to the page using <Img fadeIn={false} />.

Expected result

There should be no fading when the page loads or when navigating between pages.

Actual result

A blurred version of the image is visible for a short period of time and then fades out.

Here's an example with a version of the gatsby-astronaut.png image that's had the background made transparent. This shows what the fade looks like when the page is initialized (just navigating between cached pages here).

untitled

Environment

  System:
    OS: macOS Sierra 10.12.6
    CPU: (8) x64 Intel(R) Core(TM) i7-4850HQ CPU @ 2.30GHz
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 8.10.0 - ~/.nvm/versions/node/v8.10.0/bin/node
    Yarn: 1.12.1 - /usr/local/bin/yarn
    npm: 5.6.0 - ~/.nvm/versions/node/v8.10.0/bin/npm
  Browsers:
    Chrome: 71.0.3578.98
    Safari: 12.0.2
  npmPackages:
    gatsby: ^2.0.76 => 2.0.76 
    gatsby-image: ^2.0.20 => 2.0.25 
    gatsby-plugin-manifest: ^2.0.9 => 2.0.12 
    gatsby-plugin-offline: ^2.0.16 => 2.0.20 
    gatsby-plugin-react-helmet: ^3.0.2 => 3.0.5 
    gatsby-plugin-sharp: ^2.0.14 => 2.0.16 
    gatsby-source-filesystem: ^2.0.8 => 2.0.12 
    gatsby-transformer-sharp: ^2.1.8 => 2.1.9 
@sidharthachatterjee sidharthachatterjee added the type: question or discussion Issue discussing or asking a question about Gatsby label Jan 9, 2019
@sidharthachatterjee
Copy link
Contributor

Thank you for opening this @tylerhunt

From the documentation at https://www.gatsbyjs.org/packages/gatsby-image/

If you don’t want to use the blur-up effect, choose the fragment with noBase64 at the end. If you want to use the traced placeholder SVGs, choose the fragment with tracedSVG at the end.

Can you try removing Base64 from your query and confirm if this happens?

@tylerhunt
Copy link
Author

@sidharthachatterjee Thanks for the quick response. The _noBase64 suffix did the trick. Somehow missed the note in the documentation.

@richhiggins
Copy link
Contributor

I know this is closed.. but is the conclusion here simply to avoid using transparent PNGs with blur-up? Is the blurring up approach incompatible with transparency?

My solution was to re-save my PNGs without transparency as I'm a fan of the blur-up approach.

@polarathene
Copy link
Contributor

polarathene commented Mar 20, 2019

@richhiggins you won't be able to avoid some overlap due to transparency if you embed base64 as a placeholder graphic until the full version is available.

I've submitted a PR about a week ago that does fix this to a degree though. It's mostly focused on skipping any CSS transition when the full image is in the browser cache, but you'll have momentarily flicker of the placeholder when it's embedded until the JS kicks in and updates the DOM.

I also removed the base64 fade out transition(doesn't really have much purpose), but it will initially still have the 0.5s delay before hiding... that's probably not good for transparent images if you want to disable fadeIn, a conditional could be added to address that. EDIT: Supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question or discussion Issue discussing or asking a question about Gatsby
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants