@cryptotaxi247 / netdata-1 / commits / e60a258a4

layout trashing prevention is problematic on IE and safari - the display is out of sync; removing it again

Costa Tsaousis (ktsaou) committed Jan 5, 2017 at 02:55 UTC e60a258a41ee2d6668c9eb9fb50f430c02e3e09c
2 files changed +26 -59
web/dashboard.js
+25 -58
@@ -1160,35 +1160,6 @@ var NETDATA = window.NETDATA || {};
1160 }
1161 };
1162
1163 - // ----------------------------------------------------------------------------------------------------------------
1164 - // http://wilsonpage.co.uk/preventing-layout-thrashing/
1165 -
1166 - NETDATA.noLayoutTrashing = {
1167 - set: false,
1168 - callbacks: [],
1169 -
1170 - add: function(callback) {
1171 - // console.log('adding...');
1172 - this.callbacks.unshift(callback);
1173 -
1174 - if(this.set === false) {
1175 - this.set = true;
1176 - var that = this;
1177 -
1178 - window.requestAnimationFrame(function() {
1179 - var len = that.callbacks.length;
1180 - // console.log('running... ' + len.toString());
1181 - while(len--) {
1182 - that.callbacks[len]();
1183 - }
1184 -
1185 - that.callbacks = new Array();
1186 - that.set = false;
1187 - });
1188 - }
1189 - }
1190 - };
1191 -
1163 // ----------------------------------------------------------------------------------------------------------------
1164 // Our state object, where all per-chart values are stored
1165
@@ -1421,29 +1392,27 @@ var NETDATA = window.NETDATA || {};
1392 }
1393 that.element_legend_childs.series = null;
1394
1424 - NETDATA.noLayoutTrashing.add(function() {
1425 - if(typeof(that.width) === 'string')
1426 - $(that.element).css('width', that.width);
1427 - else if(typeof(that.width) === 'number')
1428 - $(that.element).css('width', that.width + 'px');
1429 -
1430 - if(typeof(that.library.aspect_ratio) === 'undefined') {
1431 - if(typeof(that.height) === 'string')
1432 - that.element.style.height = that.height;
1433 - else if(typeof(that.height) === 'number')
1434 - that.element.style.height = that.height.toString() + 'px';
1435 - }
1436 - else {
1437 - var w = that.element.offsetWidth;
1438 - if(w === null || w === 0) {
1439 - // the div is hidden
1440 - // this will resize the chart when next viewed
1441 - that.tm.last_resized = 0;
1442 - }
1443 - else
1444 - that.element.style.height = (w * that.library.aspect_ratio / 100).toString() + 'px';
1395 + if(typeof(that.width) === 'string')
1396 + $(that.element).css('width', that.width);
1397 + else if(typeof(that.width) === 'number')
1398 + $(that.element).css('width', that.width + 'px');
1399 +
1400 + if(typeof(that.library.aspect_ratio) === 'undefined') {
1401 + if(typeof(that.height) === 'string')
1402 + that.element.style.height = that.height;
1403 + else if(typeof(that.height) === 'number')
1404 + that.element.style.height = that.height.toString() + 'px';
1405 + }
1406 + else {
1407 + var w = that.element.offsetWidth;
1408 + if(w === null || w === 0) {
1409 + // the div is hidden
1410 + // this will resize the chart when next viewed
1411 + that.tm.last_resized = 0;
1412 }
1446 - });
1413 + else
1414 + that.element.style.height = (w * that.library.aspect_ratio / 100).toString() + 'px';
1415 + }
1416
1417 if(NETDATA.chartDefaults.min_width !== null)
1418 $(that.element).css('min-width', NETDATA.chartDefaults.min_width);
@@ -1534,12 +1503,10 @@ var NETDATA = window.NETDATA || {};
1503 };
1504
1505 var showMessageIcon = function(icon) {
1537 - NETDATA.noLayoutTrashing.add(function() {
1538 - that.element_message.innerHTML = icon;
1539 - maxMessageFontSize();
1540 - $(that.element_message).removeClass('hidden');
1541 - that.___messageHidden___ = undefined;
1542 - });
1506 + that.element_message.innerHTML = icon;
1507 + maxMessageFontSize();
1508 + $(that.element_message).removeClass('hidden');
1509 + that.___messageHidden___ = undefined;
1510 };
1511
1512 var hideMessage = function() {
@@ -1706,7 +1673,7 @@ var NETDATA = window.NETDATA || {};
1673 if(that.element_legend_childs.perfect_scroller !== null)
1674 Ps.update(that.element_legend_childs.perfect_scroller);
1675
1709 - NETDATA.noLayoutTrashing.add(maxMessageFontSize);
1676 + maxMessageFontSize();
1677 }
1678
1679 that.tm.last_resized = Date.now();
web/index.html
+1 -1
@@ -3257,4 +3257,4 @@
3257 </div>
3258 </body>
3259 </html>
3260 -<script type="text/javascript" src="dashboard.js?v20170105-1"></script>
3260 +<script type="text/javascript" src="dashboard.js?v20170105-7"></script>