Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
16 changes: 10 additions & 6 deletions spec/react-masonry-component-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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();
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eiriklv - I updated this test to account for masonry's default transitionDuration. I will look into it further, but there seems to be a timing issue when the done callback is utilized here (test fails).

}, 400 );
});

it('should correctly layout new elements when completely replacing child items [transitionDuration zero]', function() {
Expand Down