Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

window.dispatchEvent(new Event('resize')) causing infinite loop #2

Closed
TrySpace opened this issue Nov 26, 2014 · 15 comments
Closed

window.dispatchEvent(new Event('resize')) causing infinite loop #2

TrySpace opened this issue Nov 26, 2014 · 15 comments

Comments

@TrySpace
Copy link

One of my masonry's parent components is listening to the resize event, causing the componentDidUpdate of the mixin to fire, causing the resize listener to fire again..

I'm fixing this now by doing:

shouldComponentUpdate: function(nextProps, nextState){
    return nextProps.window.width !== this.props.window.width
},

in the masonry element.

But I think this could cause issues for other users as well.

I'm not sure how to prevent this in the mixin, other than triggering update on masonry manually...

@eiriklv
Copy link
Owner

eiriklv commented Dec 11, 2014

This has been fixed now :-)

@eiriklv eiriklv closed this as completed Dec 11, 2014
@eiriklv
Copy link
Owner

eiriklv commented Dec 11, 2014

No longer triggering resize event

@eiriklv eiriklv reopened this Dec 11, 2014
@eiriklv eiriklv closed this as completed Dec 11, 2014
@Chrazy
Copy link

Chrazy commented Dec 12, 2014

The changes actually trigger a weird behaviour for me. The height or the wrapper isn't calculated the same way, it gets doubled for some reason. Trying to see what could be causing it but it could be good to know that the change had an unforeseen outcome.

@Chrazy
Copy link

Chrazy commented Dec 12, 2014

Re-adding the line "this.masonry.reloadItems();" in componentWillReceiveProps seems to fix the problems I'm seeing.

@eiriklv eiriklv reopened this Dec 12, 2014
@eiriklv
Copy link
Owner

eiriklv commented Dec 12, 2014

@Chrazy Will look into it straight away :-)

@Chrazy
Copy link

Chrazy commented Dec 12, 2014

Hope you manage to reproduce my findings. Quick response time!

@eiriklv
Copy link
Owner

eiriklv commented Dec 12, 2014

Pushed new version (0.5.3 on npm) with the proposed fix. please test and report back if you have time :-)

@Chrazy
Copy link

Chrazy commented Dec 12, 2014

Seems to do the trick for me at least :)

@eiriklv
Copy link
Owner

eiriklv commented Dec 12, 2014

@Chrazy great :-) nothing else seems to break, and the addition makes sense.

@eiriklv eiriklv closed this as completed Dec 12, 2014
@Chrazy
Copy link

Chrazy commented Dec 15, 2014

I actually ran in to the same problem once again in some cases. I haven't had time to set up small case to reproduce it but reverting back to 0.4 fixes the problem for now. Should create a new issue when someone else runs into it as it's not really part of this one.

@eiriklv
Copy link
Owner

eiriklv commented Dec 15, 2014

It still happens with 0.5.3? Hmm.. what actually happens?

@eiriklv eiriklv reopened this Dec 15, 2014
@Chrazy
Copy link

Chrazy commented Dec 15, 2014

The wrapper containing the blocks gets it's height doubled, so all the blocks gets pushed down.

@Chrazy
Copy link

Chrazy commented Dec 15, 2014

It seems to be something that happens when the number of blocks are odd (I know, odd right...). I'll dig a bit more to see which commit that caused it.

@Chrazy
Copy link

Chrazy commented Dec 15, 2014

Seems like 0.5 was the commit that caused the double height actually.

@eiriklv
Copy link
Owner

eiriklv commented Dec 15, 2014

@Chrazy It would be great with a demo case that causes this, so I can test. I can't seem to reproduce it
:-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants