From 427177adc95bfede45e040d80f40be802f9a566f Mon Sep 17 00:00:00 2001 From: David Grudl Date: Mon, 26 Mar 2018 13:10:20 +0200 Subject: [PATCH] bar: support for debug bar at top of screen fixes --- src/Tracy/assets/Bar/bar.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Tracy/assets/Bar/bar.js b/src/Tracy/assets/Bar/bar.js index 03179c9f7..c0772ed61 100644 --- a/src/Tracy/assets/Bar/bar.js +++ b/src/Tracy/assets/Bar/bar.js @@ -282,7 +282,7 @@ setPosition(panel.elem, { right: pos.right - getOffset(link).left + pos.width - getPosition(link).width - 4 + getOffset(panel.elem).left, bottom: _this.isAtTop() - ? getPosition(elem).bottom - pos.height - 4 + ? getPosition(_this.elem).bottom - pos.height - 4 : pos.bottom - getOffset(elem).top + pos.height + 4 + getOffset(panel.elem).top }); } @@ -313,14 +313,15 @@ }; Bar.prototype.savePosition = function() { - var pos = getPosition(document.getElementById(this.id)); - localStorage.setItem(this.id, JSON.stringify({right: pos.right, bottom: pos.bottom})); + var pos = getPosition(this.elem), + atTop = this.isAtTop(); + localStorage.setItem(this.id, JSON.stringify({right: pos.right, bottom: pos.bottom + (atTop ? pos.height : 0), atTop: atTop})); }; Bar.prototype.restorePosition = function() { var pos = JSON.parse(localStorage.getItem(this.id)); if (pos) { - setPosition(document.getElementById(this.id), pos); + setPosition(this.elem, {right: pos.right, bottom: pos.bottom - (pos.atTop ? getPosition(this.elem).height : 0)}); } }; @@ -375,7 +376,11 @@ Debug.layer.insertAdjacentHTML('beforeend', content); evalScripts(Debug.layer); ajaxBar = document.getElementById('tracy-ajax-bar'); - document.getElementById(Bar.prototype.id).appendChild(ajaxBar); + var oldPos = getPosition(Debug.bar.elem); + Debug.bar.elem.appendChild(ajaxBar); + if (Debug.bar.isAtTop()) { + setPosition(Debug.bar.elem, {right: oldPos.right, bottom: oldPos.bottom + oldPos.height - getPosition(Debug.bar.elem).height}); + } forEach(document.querySelectorAll('.tracy-panel'), function(panel) { if (!Debug.panels[panel.id]) {