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

Visualization rendering getting cut in editor on first load #3794

Merged
merged 1 commit into from
May 13, 2019
Merged
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
16 changes: 9 additions & 7 deletions client/app/directives/resize-event.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@ const items = new Map();

function checkItems() {
items.forEach((item, node) => {
const offsetWidth = node.offsetWidth;
const offsetHeight = node.offsetHeight;
const bounds = node.getBoundingClientRect();
// convert to int (because these numbers needed for comparisons), but preserve 1 decimal point
const width = Math.round(bounds.width * 10);
const height = Math.round(bounds.height * 10);
Copy link
Contributor

Choose a reason for hiding this comment

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

This definitely works but kinda confusing cause it's not storing the actual dimensions.
Perhaps bounds.width.toFixed(1) can work?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Well, it's actually the same - just I store int, but this will store string. But in fact we just need some normalized values that we can compare. Since your variant will do exactly the same as mine, and we'll remove this directive after React migration - I prefer to keep this as is.


if (
(item.offsetWidth !== offsetWidth) ||
(item.offsetHeight !== offsetHeight)
(item.width !== width) ||
(item.height !== height)
) {
item.offsetWidth = offsetWidth;
item.offsetHeight = offsetHeight;
item.width = width;
item.height = height;
item.callback(node);
}
});

setTimeout(checkItems, 50);
setTimeout(checkItems, 100);
}

checkItems(); // ensure it was called only once!
Expand Down