Skip to content

Commit

Permalink
Fixed mobile view should be triggered on browser width shrinking #548
Browse files Browse the repository at this point in the history
  • Loading branch information
ToshMeston committed Sep 15, 2016
1 parent 4e5a1e0 commit 639fbf7
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ $(() => {
attachMobileMenuHandlers();
expandMobileQuestions();
citationTooltip();
attachChartResizeHandler();
});

// Main search bar autosuggest.
Expand Down Expand Up @@ -231,3 +232,18 @@ function citationTooltip() {
});
}

var resizeTimeout;

function attachChartResizeHandler() {
$(window).resize(() => {

if (resizeTimeout)
clearTimeout(resizeTimeout);

resizeTimeout = setTimeout(() => {
d3.selectAll('.chart h1 a').remove();
d3.selectAll('.chart-container').selectAll('*').remove();
drawCharts();
}, 300);
});
}

2 comments on commit 639fbf7

@aaasen
Copy link
Contributor

@aaasen aaasen commented on 639fbf7 Sep 15, 2016

Choose a reason for hiding this comment

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

This will make make the client call the backend to get new chart values every time the page is resized. It would be better to save the data table associated with the chart and only redraw the chart when the page is resized instead of downloading new data and creating a new data table.

@ToshMeston
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just rewrite it.

Please sign in to comment.