@@ -59,15 +59,24 @@ class LazyLoadImage extends React.Component {
5959 return false ;
6060 }
6161
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+
6273 componentDidUpdate ( ) {
6374 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 ( ) ;
6976
7077 if ( this . previousBoundingBox . bottom !== boundingBox . bottom ||
78+ this . previousBoundingBox . left !== boundingBox . left ||
79+ this . previousBoundingBox . right !== boundingBox . right ||
7180 this . previousBoundingBox . top !== boundingBox . top ) {
7281 this . updateVisibility ( ) ;
7382 }
@@ -96,14 +105,7 @@ class LazyLoadImage extends React.Component {
96105 }
97106
98107 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 ( ) ;
107109 const viewport = {
108110 bottom : scrollPosition . y + window . innerHeight ,
109111 left : scrollPosition . x ,
0 commit comments