Skip to content

Commit 10fbee6

Browse files
authored
Merge pull request #684 from interlegis/master
Limit handle position to window visible area
2 parents 849f79f + d3fcd4e commit 10fbee6

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

debug_toolbar/static/debug_toolbar/js/toolbar.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,13 @@
141141
// due to djdt.handleDragged being set to true.
142142
if (djdt.handleDragged || event.pageY != startPageY) {
143143
var top = baseY + event.clientY;
144-
144+
145145
if (top < 0) {
146146
top = 0;
147147
} else if (top + handle.height() > windowHeight) {
148148
top = windowHeight - handle.height();
149149
}
150-
150+
151151
handle.css({top: top});
152152
djdt.handleDragged = true;
153153
}
@@ -213,11 +213,13 @@
213213
$('#djDebugToolbar li').removeClass('djdt-active');
214214
// finally close toolbar
215215
$('#djDebugToolbar').hide('fast');
216-
$('#djDebugToolbarHandle').show();
216+
handle = $('#djDebugToolbarHandle')
217+
handle.show();
217218
// set handle position
218219
var handleTop = djdt.cookie.get('djdttop');
219220
if (handleTop) {
220-
$('#djDebugToolbarHandle').css({top: handleTop + 'px'});
221+
handleTop = Math.min(handleTop, window.innerHeight - handle.outerHeight() - 10)
222+
handle.css({top: handleTop + 'px'});
221223
}
222224
// Unbind keydown
223225
$(document).unbind('keydown.djDebug');

0 commit comments

Comments
 (0)