Skip to content

Commit

Permalink
fix(performance): Performance improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
wcandillon committed May 2, 2017
1 parent 749987f commit 322f299
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,11 @@ export class ProgressiveImage extends React.Component<ProgressiveImageProps & Di
;
}

private fetch(uri: string): Promise<string> {
private fetch(src: string): Promise<string> {
return new Promise(resolve => {
fetch(uri)
.then(response => response.blob())
.then(blob => {
const fp = new FileReader();
fp.onload = () => {
resolve(fp.result as string);
};
fp.readAsDataURL(blob);
});
const image = new Image();
image.src = src;
image.addEventListener("load", () => resolve(src), false);
});
}

Expand Down

0 comments on commit 322f299

Please sign in to comment.