Move width and height to onLoad. Document dimensions event.

This commit is contained in:
Dylan Vann 2018-03-17 20:05:24 -04:00
parent eb78e9c2cd
commit 60130cb326
3 changed files with 9 additions and 8 deletions

View File

@ -114,9 +114,11 @@ e.g. `onProgress={e => console.log(e.nativeEvent.loaded / e.nativeEvent.total)}`
---
### `onLoad?: () => void`
### `onLoad?: (event) => void`
Called on a successful image fetch.
Called on a successful image fetch. Called with the width and height of the loaded image.
e.g. `onLoad={e => console.log(e.nativeEvent.width, e.nativeEvent.height)}`
---

View File

@ -104,16 +104,15 @@
}
} else {
hasCompleted = YES;
if (_onFastImageLoad) {
_onFastImageLoad(@{});
}
NSDictionary* params = @{
@"width":[NSNumber numberWithDouble:image.size.width],
@"height":[NSNumber numberWithDouble:image.size.height]
};
if (_onFastImageLoad) {
_onFastImageLoad(params);
}
if (_onFastImageLoadEnd) {
_onFastImageLoadEnd(params);
_onFastImageLoadEnd(@{});
}
}
}];

View File

@ -14,7 +14,7 @@ const getTestProgressCallbacks = label => ({
console.log(
`${label} - onProgress - ${e.nativeEvent.loaded / e.nativeEvent.total}`,
),
onLoad: () => console.log(`${label} - onLoad`),
onLoad: (e) => console.log(`${label} - onLoad`, e.nativeEvent),
onError: () => console.log(`${label} - onError`),
onLoadEnd: () => console.log(`${label} - onLoadEnd`),
})