From 72383bd4db91e54904d66835280db54a5136b9a0 Mon Sep 17 00:00:00 2001 From: Kyra Steenbock Date: Thu, 14 Jun 2018 17:27:45 -0700 Subject: [PATCH 1/2] only prepend if not already reloading --- lib/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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); From 07112562106e6f158d376062ca5e5c3b225ab1ff Mon Sep 17 00:00:00 2001 From: Kyra Steenbock Date: Tue, 19 Jun 2018 14:56:27 -0700 Subject: [PATCH 2/2] updated spec to account for default transitionDuration before asserting expectations --- spec/react-masonry-component-test.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) 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() {