@@ -59,15 +59,24 @@ class LazyLoadImage extends React.Component {
59
59
return false ;
60
60
}
61
61
62
+ getPlaceholderBoundingBox ( ) {
63
+ return {
64
+ bottom : this . placeholder . offsetTop +
65
+ this . placeholder . offsetHeight ,
66
+ left : this . placeholder . offsetLeft ,
67
+ right : this . placeholder . offsetLeft +
68
+ this . placeholder . offsetWidth ,
69
+ top : this . placeholder . offsetTop
70
+ } ;
71
+ }
72
+
62
73
componentDidUpdate ( ) {
63
74
if ( this . placeholder ) {
64
- const boundingBox = {
65
- bottom : this . placeholder . offsetTop +
66
- this . placeholder . offsetHeight ,
67
- top : this . placeholder . offsetTop
68
- } ;
75
+ const boundingBox = this . getPlaceholderBoundingBox ( ) ;
69
76
70
77
if ( this . previousBoundingBox . bottom !== boundingBox . bottom ||
78
+ this . previousBoundingBox . left !== boundingBox . left ||
79
+ this . previousBoundingBox . right !== boundingBox . right ||
71
80
this . previousBoundingBox . top !== boundingBox . top ) {
72
81
this . updateVisibility ( ) ;
73
82
}
@@ -96,14 +105,7 @@ class LazyLoadImage extends React.Component {
96
105
}
97
106
98
107
const { threshold } = this . props ;
99
- const boundingBox = {
100
- bottom : this . placeholder . offsetTop +
101
- this . placeholder . offsetHeight ,
102
- left : this . placeholder . offsetLeft ,
103
- right : this . placeholder . offsetLeft +
104
- this . placeholder . offsetWidth ,
105
- top : this . placeholder . offsetTop
106
- } ;
108
+ const boundingBox = this . getPlaceholderBoundingBox ( ) ;
107
109
const viewport = {
108
110
bottom : scrollPosition . y + window . innerHeight ,
109
111
left : scrollPosition . x ,
0 commit comments