Skip to content

Commit

Permalink
Resize markmap container on window resize #1496
Browse files Browse the repository at this point in the history
  • Loading branch information
miteshashar committed Oct 27, 2022
1 parent 289dda2 commit 499566e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions funnel/assets/js/utils/markmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ const MarkmapEmbed = {
$(this).addClass('activated');
});
},
resizeTimer: null,
resizeMarkmapContainers() {
if (this.resizeTimer) clearTimeout(this.resizeTimer);
this.resizeTimer = setTimeout(() => {
$('.md-embed-markmap.activated svg').each(function mmresized() {
const circles = $(this).find('circle');
const firstNode = circles[circles.length - 1];
firstNode.dispatchEvent(new Event('click'));
firstNode.dispatchEvent(new Event('click'));
});
}, 500);
},
loadMarkmap() {
const self = this;
const CDN = [
Expand Down Expand Up @@ -43,6 +55,7 @@ const MarkmapEmbed = {
loadMarkmapScript();
} else {
self.addMarkmap();
window.addEventListener('resize', this.resizeMarkmapContainers);
}
});
};
Expand Down

0 comments on commit 499566e

Please sign in to comment.