Skip to content

Commit

Permalink
#3753 resize-event: take into account transformations and transitions
Browse files Browse the repository at this point in the history
  • Loading branch information
kravets-levko committed May 13, 2019
1 parent b09ae46 commit ecf97f5
Showing 1 changed file with 9 additions and 7 deletions.
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);

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

0 comments on commit ecf97f5

Please sign in to comment.