@cryptotaxi247 / netdata-1 / commits / d6a9a3eba

eliminated most start browser reflows

Costa Tsaousis (ktsaou) committed Jun 4, 2017 at 22:12 UTC d6a9a3eba6ff2257f69d97a311fa984b921aaee2
1 file changed +16 -15
web/dashboard.js
+16 -15
@@ -1769,7 +1769,7 @@ var NETDATA = window.NETDATA || {};
1769 }
1770 else {
1771 var w = that.element.offsetWidth;
1772 - if(w === null || w === 0) {
1772 + if (w === null || w === 0) {
1773 // the div is hidden
1774 // this will resize the chart when next viewed
1775 that.tm.last_resized = 0;
@@ -1821,17 +1821,18 @@ var NETDATA = window.NETDATA || {};
1821 * destroy all (possibly) created state elements
1822 * create the basic DOM for a chart
1823 */
1824 - var init = function(force) {
1824 + var init = function(opt) {
1825 if(that.enabled === false) return;
1826 - if(typeof(force) === 'undefined') force = false;
1826
1827 runtimeInit();
1828
1829 that.tm.last_initialized = Date.now();
1830 that.setMode('auto');
1831
1833 - if(that.isVisible(true) || force === true)
1834 - createDOM();
1832 + if(opt !== 'fast') {
1833 + if (that.isVisible(true) || opt === 'force')
1834 + createDOM();
1835 + }
1836 };
1837
1838 var maxMessageFontSize = function() {
@@ -1916,7 +1917,7 @@ var NETDATA = window.NETDATA || {};
1917 if(that.chart_created === true) {
1918 if(NETDATA.options.current.destroy_on_hide === true) {
1919 // we should destroy it
1919 - init(true);
1920 + init('force');
1921 }
1922 else {
1923 showRendering();
@@ -1948,7 +1949,7 @@ var NETDATA = window.NETDATA || {};
1949 if(that.chart_created === false) {
1950 // we need to re-initialize it, to show our background
1951 // logo in bootstrap tabs, until the chart loads
1951 - init(true);
1952 + init('force');
1953 }
1954 else {
1955 that.tm.last_unhidden = Date.now();
@@ -2030,7 +2031,7 @@ var NETDATA = window.NETDATA || {};
2031 if(that.chart_created === false) return;
2032
2033 if(that.needsRecreation()) {
2033 - init(true);
2034 + init('force');
2035 }
2036 else if(typeof that.library.resize === 'function') {
2037 that.library.resize(that);
@@ -3086,7 +3087,7 @@ var NETDATA = window.NETDATA || {};
3087 title: 'Chart Reset',
3088 content: 'Reset all the charts to their default auto-refreshing state. You can also <b>double click</b> the chart contents with your mouse or your finger (on touch devices).<br/><small>Help, can be disabled from the settings.</small>'
3089 });
3089 -
3090 +
3091 this.element_legend_childs.toolbox_right.className += ' netdata-legend-toolbox-button';
3092 this.element_legend_childs.toolbox_right.innerHTML = '<i class="fa fa-forward"></i>';
3093 this.element_legend_childs.toolbox.appendChild(this.element_legend_childs.toolbox_right);
@@ -3110,7 +3111,7 @@ var NETDATA = window.NETDATA || {};
3111 content: 'Pan the chart to the right. You can also <b>drag it</b> with your mouse or your finger (on touch devices).<br/><small>Help, can be disabled from the settings.</small>'
3112 });
3113
3113 -
3114 +
3115 this.element_legend_childs.toolbox_zoomin.className += ' netdata-legend-toolbox-button';
3116 this.element_legend_childs.toolbox_zoomin.innerHTML = '<i class="fa fa-plus"></i>';
3117 this.element_legend_childs.toolbox.appendChild(this.element_legend_childs.toolbox_zoomin);
@@ -3132,7 +3133,7 @@ var NETDATA = window.NETDATA || {};
3133 title: 'Chart Zoom In',
3134 content: 'Zoom in the chart. You can also press SHIFT and select an area of the chart to zoom in. On Chrome and Opera, you can press the SHIFT or the ALT keys and then use the mouse wheel to zoom in or out.<br/><small>Help, can be disabled from the settings.</small>'
3135 });
3135 -
3136 +
3137 this.element_legend_childs.toolbox_zoomout.className += ' netdata-legend-toolbox-button';
3138 this.element_legend_childs.toolbox_zoomout.innerHTML = '<i class="fa fa-minus"></i>';
3139 this.element_legend_childs.toolbox.appendChild(this.element_legend_childs.toolbox_zoomout);
@@ -3155,7 +3156,7 @@ var NETDATA = window.NETDATA || {};
3156 title: 'Chart Zoom Out',
3157 content: 'Zoom out the chart. On Chrome and Opera, you can also press the SHIFT or the ALT keys and then use the mouse wheel to zoom in or out.<br/><small>Help, can be disabled from the settings.</small>'
3158 });
3158 -
3159 +
3160 //this.element_legend_childs.toolbox_volume.className += ' netdata-legend-toolbox-button';
3161 //this.element_legend_childs.toolbox_volume.innerHTML = '<i class="fa fa-sort-amount-desc"></i>';
3162 //this.element_legend_childs.toolbox_volume.title = 'Visible Volume';
@@ -3174,7 +3175,7 @@ var NETDATA = window.NETDATA || {};
3175 this.element_legend_childs.toolbox_zoomout = null;
3176 this.element_legend_childs.toolbox_volume = null;
3177 }
3177 -
3178 +
3179 this.element_legend_childs.resize_handler.className += " netdata-legend-resize-handler";
3180 this.element_legend_childs.resize_handler.innerHTML = '<i class="fa fa-chevron-up"></i><i class="fa fa-chevron-down"></i>';
3181 this.element.appendChild(this.element_legend_childs.resize_handler);
@@ -3511,7 +3512,7 @@ var NETDATA = window.NETDATA || {};
3512 if(this.debug === true)
3513 this.log('max updates of ' + this.updates_since_last_creation.toString() + ' reached. Forcing re-generation.');
3514
3514 - init(true);
3515 + init('force');
3516 return;
3517 }
3518
@@ -3888,7 +3889,7 @@ var NETDATA = window.NETDATA || {};
3889 // INITIALIZATION
3890
3891 initDOM();
3891 - init();
3892 + init('fast');
3893 };
3894
3895 NETDATA.resetAllCharts = function(state) {