Skip to content

Commit 7ac33a2

Browse files
committed
bar: support for debug bar at top of screen AJAX fixes
1 parent ead5141 commit 7ac33a2

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/Tracy/assets/Bar/bar.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@
282282
setPosition(panel.elem, {
283283
right: pos.right - getOffset(link).left + pos.width - getPosition(link).width - 4 + getOffset(panel.elem).left,
284284
bottom: _this.isAtTop()
285-
? getPosition(elem).bottom - pos.height - 4
285+
? getPosition(_this.elem).bottom - pos.height - 4
286286
: pos.bottom - getOffset(elem).top + pos.height + 4 + getOffset(panel.elem).top
287287
});
288288
}
@@ -313,14 +313,15 @@
313313
};
314314

315315
Bar.prototype.savePosition = function() {
316-
var pos = getPosition(document.getElementById(this.id));
317-
localStorage.setItem(this.id, JSON.stringify({right: pos.right, bottom: pos.bottom}));
316+
var pos = getPosition(this.elem),
317+
atTop = this.isAtTop();
318+
localStorage.setItem(this.id, JSON.stringify({right: pos.right, bottom: pos.bottom + (atTop ? pos.height : 0), atTop: atTop}));
318319
};
319320

320321
Bar.prototype.restorePosition = function() {
321322
var pos = JSON.parse(localStorage.getItem(this.id));
322323
if (pos) {
323-
setPosition(document.getElementById(this.id), pos);
324+
setPosition(this.elem, {right: pos.right, bottom: pos.bottom - (pos.atTop ? getPosition(this.elem).height : 0)});
324325
}
325326
};
326327

@@ -375,7 +376,11 @@
375376
Debug.layer.insertAdjacentHTML('beforeend', content);
376377
evalScripts(Debug.layer);
377378
ajaxBar = document.getElementById('tracy-ajax-bar');
378-
document.getElementById(Bar.prototype.id).appendChild(ajaxBar);
379+
var oldPos = getPosition(Debug.bar.elem);
380+
Debug.bar.elem.appendChild(ajaxBar);
381+
if (Debug.bar.isAtTop()) {
382+
setPosition(Debug.bar.elem, {right: oldPos.right, bottom: oldPos.bottom + oldPos.height - getPosition(Debug.bar.elem).height});
383+
}
379384

380385
forEach(document.querySelectorAll('.tracy-panel'), function(panel) {
381386
if (!Debug.panels[panel.id]) {

0 commit comments

Comments
 (0)