};
updateStickyBadges = (forceBadgeAlignement /*: ?boolean */) => {
- if (this.scrollContainer && this.badges) {
- const scrollTop = this.scrollContainer.scrollTop;
- if (scrollTop != null) {
- let newScrollTop;
- for (let i = 1; i < this.badges.length; i++) {
- const badge = this.badges[i];
- let originOffsetTop = badge.getAttribute('originOffsetTop');
- if (originOffsetTop == null) {
- // Set the originOffsetTop attribute, to avoid using getBoundingClientRect
- originOffsetTop = badge.offsetTop;
- badge.setAttribute('originOffsetTop', originOffsetTop.toString());
- }
- if (Number(originOffsetTop) < scrollTop + 18 + i * 2) {
- if (forceBadgeAlignement && !badge.classList.contains('sticky')) {
- newScrollTop = originOffsetTop;
- }
- badge.classList.add('sticky');
- } else {
- badge.classList.remove('sticky');
- }
- }
- if (forceBadgeAlignement && newScrollTop != null) {
- this.scrollContainer.scrollTop = newScrollTop - 6;
+ if (!this.scrollContainer || !this.badges) {
+ return;
+ }
+
+ const scrollTop = this.scrollContainer.scrollTop;
+ if (scrollTop == null) {
+ return;
+ }
+
+ let newScrollTop;
+ for (let i = 1; i < this.badges.length; i++) {
+ const badge = this.badges[i];
+ let originOffsetTop = badge.getAttribute('originOffsetTop');
+ if (originOffsetTop == null) {
+ // Set the originOffsetTop attribute, to avoid using getBoundingClientRect
+ originOffsetTop = badge.offsetTop;
+ badge.setAttribute('originOffsetTop', originOffsetTop.toString());
+ }
+ if (Number(originOffsetTop) < scrollTop + 18 + i * 2) {
+ if (forceBadgeAlignement && !badge.classList.contains('sticky')) {
+ newScrollTop = originOffsetTop;
}
+ badge.classList.add('sticky');
+ } else {
+ badge.classList.remove('sticky');
}
}
+
+ if (forceBadgeAlignement && newScrollTop != null) {
+ this.scrollContainer.scrollTop = newScrollTop - 6;
+ }
};
updateSelectedDate = (date /*: Date */) => this.props.updateQuery({ selectedDate: date });
renderLink = () => {
const { link, height, width } = this.props;
- if (link != null && width >= 24 && height >= 24 && (width >= 48 || height >= 50)) {
- return (
- <Link className="treemap-link" to={link} onClick={this.handleLinkClick}>
- <LinkIcon />
- </Link>
- );
+ const hasMinSize = width >= 24 && height >= 24 && (width >= 48 || height >= 50);
+ if (!hasMinSize || link == null) {
+ return null;
}
+ return (
+ <Link className="treemap-link" to={link} onClick={this.handleLinkClick}>
+ <LinkIcon />
+ </Link>
+ );
};
renderCell = () => {