@@ -55,6 +55,7 @@ export default class MasonryList extends React.PureComponent {
5555 ] ) ,
5656
5757 onImageResolved : PropTypes . func ,
58+ onImagesResolveEnd : PropTypes . func ,
5859
5960 onPressImage : PropTypes . func ,
6061 onLongPressImage : PropTypes . func ,
@@ -69,6 +70,7 @@ export default class MasonryList extends React.PureComponent {
6970 _sortedData : [ ]
7071 }
7172
73+ doneTotal = 0 ;
7274 unsortedIndex = 0 ;
7375 renderIndex = 0 ;
7476
@@ -289,6 +291,14 @@ export default class MasonryList extends React.PureComponent {
289291 ( err ) => {
290292 // eslint-disable-next-line handle-callback-err, no-console
291293 console . warn ( "react-native-masonry-list" , "Image failed to load." , err ) ;
294+
295+ this . doneTotal ++ ;
296+ if (
297+ this . props . onImagesResolveEnd &&
298+ this . doneTotal === this . props . images . length
299+ ) {
300+ this . props . onImagesResolveEnd ( this . state . _sortedData , this . doneTotal ) ;
301+ }
292302 } ,
293303 ( resolvedImages ) => {
294304 resolvedImages . map ( ( resolvedData , i ) => {
@@ -326,6 +336,14 @@ export default class MasonryList extends React.PureComponent {
326336 this . setState ( {
327337 _sortedData : sortedData
328338 } ) ;
339+
340+ this . doneTotal ++ ;
341+ if (
342+ this . props . onImagesResolveEnd &&
343+ this . doneTotal === this . props . images . length
344+ ) {
345+ this . props . onImagesResolveEnd ( this . state . _sortedData , this . doneTotal ) ;
346+ }
329347 }
330348 } ) ;
331349 } ) ;
@@ -336,6 +354,14 @@ export default class MasonryList extends React.PureComponent {
336354 ( err ) => {
337355 // eslint-disable-next-line handle-callback-err, no-console
338356 console . warn ( "react-native-masonry-list" , "Image failed to load." , err ) ;
357+
358+ this . doneTotal ++ ;
359+ if (
360+ this . props . onImagesResolveEnd &&
361+ this . doneTotal === this . props . images . length
362+ ) {
363+ this . props . onImagesResolveEnd ( this . state . _sortedData , this . doneTotal ) ;
364+ }
339365 } ,
340366 ( resolvedData ) => {
341367 resolvedData . index = this . unsortedIndex ;
@@ -374,6 +400,14 @@ export default class MasonryList extends React.PureComponent {
374400 _sortedData : sortedData
375401 } ) ;
376402 }
403+
404+ this . doneTotal ++ ;
405+ if (
406+ this . props . onImagesResolveEnd &&
407+ this . doneTotal === this . props . images . length
408+ ) {
409+ this . props . onImagesResolveEnd ( this . state . _sortedData , this . doneTotal ) ;
410+ }
377411 } ) ;
378412 }
379413 } ) ;
@@ -425,6 +459,14 @@ export default class MasonryList extends React.PureComponent {
425459 ( err ) => {
426460 // eslint-disable-next-line handle-callback-err, no-console
427461 console . warn ( "react-native-masonry-list" , "Image failed to load." , err ) ;
462+
463+ this . doneTotal ++ ;
464+ if (
465+ this . props . onImagesResolveEnd &&
466+ this . doneTotal === this . props . images . length
467+ ) {
468+ this . props . onImagesResolveEnd ( this . state . _sortedData , this . doneTotal ) ;
469+ }
428470 } ,
429471 ( resolvedImages ) => {
430472 resolvedImages . map ( ( resolvedImage , i ) => {
@@ -460,6 +502,14 @@ export default class MasonryList extends React.PureComponent {
460502 _sortedData : sortedData
461503 } ) ;
462504 }
505+
506+ this . doneTotal ++ ;
507+ if (
508+ this . props . onImagesResolveEnd &&
509+ this . doneTotal === this . props . images . length
510+ ) {
511+ this . props . onImagesResolveEnd ( this . state . _sortedData ) ;
512+ }
463513 } ) ;
464514 } ) ;
465515 } else {
@@ -469,6 +519,14 @@ export default class MasonryList extends React.PureComponent {
469519 ( err ) => {
470520 // eslint-disable-next-line handle-callback-err, no-console
471521 console . warn ( "react-native-masonry-list" , "Image failed to load." , err ) ;
522+
523+ this . doneTotal ++ ;
524+ if (
525+ this . props . onImagesResolveEnd &&
526+ this . doneTotal === this . props . images . length
527+ ) {
528+ this . props . onImagesResolveEnd ( this . state . _sortedData , this . doneTotal ) ;
529+ }
472530 } ,
473531 ( resolvedImage ) => {
474532 resolvedImage . index = this . unsortedIndex ;
@@ -504,6 +562,14 @@ export default class MasonryList extends React.PureComponent {
504562 _sortedData : sortedData
505563 } ) ;
506564 }
565+
566+ this . doneTotal ++ ;
567+ if (
568+ this . props . onImagesResolveEnd &&
569+ this . doneTotal === this . props . images . length
570+ ) {
571+ this . props . onImagesResolveEnd ( this . state . _sortedData ) ;
572+ }
507573 } ) ;
508574 }
509575 } ) ;
0 commit comments