diff --git a/lib/index.js b/lib/index.js index b1ad8c7..4d43460 100644 --- a/lib/index.js +++ b/lib/index.js @@ -203,7 +203,9 @@ var MasonryComponent = createReactClass({ } if (diff.prepended.length > 0) { - this.masonry.prepended(diff.prepended); + if (!reloadItems) { + this.masonry.prepended(diff.prepended); + } if (this.props.enableResizableChildren) { diff.prepended.forEach(this.listenToElementResize, this); diff --git a/spec/react-masonry-component-test.js b/spec/react-masonry-component-test.js index 4a77281..ab7686e 100644 --- a/spec/react-masonry-component-test.js +++ b/spec/react-masonry-component-test.js @@ -287,7 +287,7 @@ describe('React Masonry Component', function() { } }; - it('should correctly layout new elements when completely replacing child items [transitionDuration empty]', function() { + it('should correctly layout new elements when completely replacing child items [transitionDuration empty]', function(/*done*/) { let wrapperContext; class Wrapper extends React.Component { constructor() { @@ -326,12 +326,16 @@ describe('React Masonry Component', function() { } wrapperContext.setState({items: childrenElements.slice().reverse()}); - const secondElements = div.querySelectorAll('.item'); - for (let i = 0; i < secondElements.length; i++) { - expect(secondElements[i].style.left).toEqual(secondPositions[i].left + 'px'); - expect(secondElements[i].style.top).toEqual(secondPositions[i].top + 'px'); - } + setTimeout(() => { + const secondElements = div.querySelectorAll('.item'); + + for (let i = 0; i < secondElements.length; i++) { + expect(secondElements[i].style.left).toEqual(secondPositions[i].left + 'px'); + expect(secondElements[i].style.top).toEqual(secondPositions[i].top + 'px'); + } + // done(); + }, 400 ); }); it('should correctly layout new elements when completely replacing child items [transitionDuration zero]', function() {