@cryptotaxi247 / netdata-1 / commits / 962176cc1

added option to enable/disable intersection observer (still enabled by default); detected a case that the chart library draws the chart while hidden and triggered a redraw when this happens; #3289

Costa Tsaousis (ktsaou) committed Jan 15, 2018 at 13:26 UTC 962176cc16a2502476c94b2e9d1d4f2bdb0c0575
2 files changed +34 -9
web/dashboard.js
+33 -8
@@ -51,6 +51,8 @@
51 * (default: null) */
52 /*global netdataAlarmsRecipients *//* array, an array of alarm recipients to show notifications for
53 * (default: null) */
54 +/*global netdataIntersectionObserver *//* boolean, enable or disable the use of intersection observer
55 + * (default: true) */
56
57 // ----------------------------------------------------------------------------
58 // global namespace
@@ -2545,13 +2547,18 @@ var NETDATA = window.NETDATA || {};
2547 },
2548
2549 init: function() {
2548 - try {
2549 - this.observer = new IntersectionObserver(this.handler, this.options);
2550 - }
2551 - catch(e) {
2552 - console.log("IntersectionObserver is not supported on this browser");
2553 - this.observer = null;
2550 + if(typeof netdataIntersectionObserver === 'undefined' || netdataIntersectionObserver === true) {
2551 + try {
2552 + this.observer = new IntersectionObserver(this.handler, this.options);
2553 + }
2554 + catch (e) {
2555 + console.log("IntersectionObserver is not supported on this browser");
2556 + this.observer = null;
2557 + }
2558 }
2559 + //else {
2560 + // console.log("IntersectionObserver is disabled");
2561 + //}
2562 }
2563 };
2564 NETDATA.intersectionObserver.init();
@@ -3069,6 +3076,15 @@ var NETDATA = window.NETDATA || {};
3076 resizeChart();
3077 hideMessage();
3078 }
3079 +
3080 + if(this.__redraw_on_unhide === true) {
3081 +
3082 + if(this.debug === true)
3083 + this.log("redrawing chart on unhide");
3084 +
3085 + this.__redraw_on_unhide = undefined;
3086 + this.redrawChart();
3087 + }
3088 };
3089
3090 var canBeRendered = function(uncached_visibility) {
@@ -4666,8 +4682,17 @@ var NETDATA = window.NETDATA || {};
4682 if(callChartLibraryCreateSafely(data) === false)
4683 return;
4684 }
4669 - hideMessage();
4670 - this.legendShowLatestValues();
4685 + if(this.isVisible() === true) {
4686 + hideMessage();
4687 + this.legendShowLatestValues();
4688 + }
4689 + else {
4690 + this.__redraw_on_unhide = true;
4691 +
4692 + if(this.debug === true)
4693 + this.log("drawn while not visible")
4694 + }
4695 +
4696 if(this.selected === true)
4697 NETDATA.globalSelectionSync.stop();
4698
web/index.html
+1 -1
@@ -5622,6 +5622,6 @@
5622 </div>
5623 </div>
5624 <div id="hiddenDownloadLinks" style="display: none;" hidden></div>
5625 - <script type="text/javascript" src="dashboard.js?v20180115-1"></script>
5625 + <script type="text/javascript" src="dashboard.js?v20180115-2"></script>
5626 </body>
5627 </html>