You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix passing onLoad overwrites, and call onLoad inside onImageLoad (#120)
* Fix onLoad overwrite and call onLoad
- Fix onLoad getting overwritten by props which cause `onImageLoad()` to never get called.
- preserve the functionality of `onLoad` by adding a callback.
* Attach event to afterLoad and update docs
* Update src/components/LazyLoadImage.jsx
Co-authored-by: Albert Juhé Lluveras <[email protected]>
* Mark afterLoad as deprecated
* Update test
---------
Co-authored-by: Albert Juhé Lluveras <[email protected]>
Copy file name to clipboardExpand all lines: README.md
+5-3Lines changed: 5 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ React Component to lazy load images and other components/elements. Supports Inte
24
24
* A custom placeholder component or image can be specified.
25
25
* Built-in on-visible effects (blur, black and white and opacity transitions).
26
26
* threshold is set to 100px by default and can be modified.
27
-
*`beforeLoad` and `afterLoad` events.
27
+
*`beforeLoad` and `onLoad` events.
28
28
*`debounce` and `throttle` included by default and configurable.
29
29
* Uses IntersectionObserver for browsers that support it.
30
30
* Server Side Rendering (SSR) compatible.
@@ -66,7 +66,8 @@ export default MyImage;
66
66
67
67
| Prop | Type | Default | Description |
68
68
|:---|:---|:---|:---|
69
-
| afterLoad |`Function`|| Function called after the image has been completely loaded. |
69
+
| onLoad |`Function`|| Function called when the image has been loaded. This is the same function as the `onLoad` of a `<img>` which contains an event object. |
70
+
| afterLoad |`Function`|| Deprecated, use `onLoad` instead. This props is only for backward compatibility. |
70
71
| beforeLoad |`Function`|| Function called right before the placeholder is replaced with the image element. |
71
72
| delayMethod |`String`|`throttle`| Method from lodash to use to delay the scroll/resize events. It can be `throttle` or `debounce`. |
72
73
| delayTime |`Number`| 300 | Time in ms sent to the delayMethod. |
@@ -188,7 +189,8 @@ You must set the prop `scrollPosition` to the lazy load components. This way, th
188
189
| Prop | Type | Default | Description |
189
190
|:---|:---|:---|:---|
190
191
| scrollPosition |`Object`|| Object containing `x` and `y` with the curent window scroll position. Required. |
191
-
| afterLoad |`Function`|| Function called after the image has been rendered. |
192
+
| onLoad |`Function`|| Function called when the image has been loaded. This is the same function as the `onLoad` of a `<img>` which contains an event object. |
193
+
| afterLoad |`Function`|| Deprecated, use `onLoad` instead. This props is only for backward compatibility. |
192
194
| beforeLoad |`Function`|| Function called right before the image is rendered. |
193
195
| placeholder |`ReactClass`|`<span>`| React element to use as a placeholder. |
194
196
| threshold |`Number`| 100 | Threshold in pixels. So the image starts loading before it appears in the viewport. |
0 commit comments