-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gatsby-image): add onStartLoad prop (#6702)
* implementation of the onStartLoad handler for gatsby-image * update to typescript declarations of gatsby-image * changed double quotes to backticks * updated declaration file to better represent current state of gatsby-image * make sure onStartLoad is only fired once * fixed image cache information store provide cache information in the onStartLoad handler * updatede readme * better name for cache setter * lint fix
- Loading branch information
Showing
3 changed files
with
70 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,48 @@ | ||
import * as React from "react"; | ||
import * as React from "react" | ||
|
||
interface FixedObject { | ||
width: number | ||
height: number | ||
src: string | ||
srcSet: string | ||
base64?: string | ||
tracedSVG?: string | ||
srcWebp?: string | ||
srcSetWebp?: string | ||
} | ||
|
||
interface FluidObject { | ||
aspectRatio: number | ||
src: string | ||
srcSet: string | ||
sizes: string | ||
base64: string | ||
tracedSVG: string | ||
srcWebp: string | ||
srcSetWebp: string | ||
} | ||
|
||
interface GatsbyImageProps { | ||
resolutions?: object; | ||
sizes?: object; | ||
fixed?: object; | ||
fluid?: object; | ||
fadeIn?: boolean; | ||
title?: string; | ||
alt?: string; | ||
className?: string | object; | ||
critical?: boolean; | ||
style?: object; | ||
imgStyle?: object; | ||
placeholderStyle?: object; | ||
backgroundColor?: string | boolean; | ||
onLoad?: (event: any) => void; | ||
onError?: (event: any) => void; | ||
Tag?: string; | ||
resolutions?: FixedObject | ||
sizes?: FluidObject | ||
fixed?: FixedObject | ||
fluid?: FluidObject | ||
fadeIn?: boolean | ||
title?: string | ||
alt?: string | ||
className?: string | object | ||
critical?: boolean | ||
style?: object | ||
imgStyle?: object | ||
placeholderStyle: object | ||
backgroundColor?: string | boolean | ||
onLoad?: () => void | ||
onStartLoad?: (param: { wasCached: boolean }) => void | ||
onError?: (event: any) => void | ||
Tag?: string | ||
} | ||
|
||
export default class GatsbyImage extends React.Component<GatsbyImageProps, any> {} | ||
export default class GatsbyImage extends React.Component< | ||
GatsbyImageProps, | ||
any | ||
> {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters