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

Error when switching between layouts #118

Closed
andrecardoso opened this issue Aug 21, 2014 · 1 comment · Fixed by #119
Closed

Error when switching between layouts #118

andrecardoso opened this issue Aug 21, 2014 · 1 comment · Fixed by #119

Comments

@andrecardoso
Copy link
Contributor

When I switch from Crocodoc.LAYOUT_HORIZONTAL to Crocodoc.LAYOUT_VERTICAL it happens an error (TypeError: Cannot read property 'width' of undefined) and the vertical layout is not set right.

I've checked the code and figured out that the problem happens because viewerBase.setLayout broadcasts a layoutchange message before returning. This message is caught by viewer-base that calls viewer.updateLayout that is still with the old (but already destroyed) layout reference.

A simple solution is to change the viewer.setLayout method and nullify the layout reference before calling viewerBase.setLayout. That way, the old reference doesn't exist anymore when the message is handled. I tested it myself and it worked fine.

Is this the best solution? I could open a pull request with this change if necessary.

Thanks.

@lakenen
Copy link
Contributor

lakenen commented Aug 21, 2014

@andrecardoso good catch! Yes, it looks like your approach will work. Feel free to submit a pull request.

Could you also include a comment explaining why the change is necessary (you could even link to this issue). Thanks!

andrecardoso added a commit to andrecardoso/viewer.js that referenced this issue Aug 21, 2014
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

Successfully merging a pull request may close this issue.

2 participants