Skip to content

Instantly share code, notes, and snippets.

@ajmalafif
Last active November 27, 2020 08:54
Show Gist options
  • Select an option

  • Save ajmalafif/08d2915778d519650d6592db9e0f0186 to your computer and use it in GitHub Desktop.

Select an option

Save ajmalafif/08d2915778d519650d6592db9e0f0186 to your computer and use it in GitHub Desktop.
[sanity + gatsby] Figuring out jank-free, lqip image loading
@ajmalafif

ajmalafif commented Nov 27, 2020

Copy link
Copy Markdown
Author

Figured it out

<figure
    style={{
        position: 'relative',
        overflow: 'hidden',
        margin: 0,
        width: '50%'
      }}>
      <div
      style={{
        paddingBottom: '56.25%'
      }}></div>
      <SanityImage
        {...props.mainImage}
        sx={{
          '&[data-lqip]': {
            display: 'block',
          position: 'absolute',
          top: 0,
          left: 0,
          width: '100%',
          }
        }}
        style={{ 
          display: 'block',
          position: 'absolute',
          top: 0,
          left: 0,
          width: '100%',
          height: '100%'
        }}
      />
</figure>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment