Skip to content

Limit handle position to window visible area #684

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 21, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions debug_toolbar/static/debug_toolbar/js/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,13 @@
// due to djdt.handleDragged being set to true.
if (djdt.handleDragged || event.pageY != startPageY) {
var top = baseY + event.clientY;

if (top < 0) {
top = 0;
} else if (top + handle.height() > windowHeight) {
top = windowHeight - handle.height();
}

handle.css({top: top});
djdt.handleDragged = true;
}
Expand Down Expand Up @@ -213,11 +213,13 @@
$('#djDebugToolbar li').removeClass('djdt-active');
// finally close toolbar
$('#djDebugToolbar').hide('fast');
$('#djDebugToolbarHandle').show();
handle = $('#djDebugToolbarHandle')
handle.show();
// set handle position
var handleTop = djdt.cookie.get('djdttop');
if (handleTop) {
$('#djDebugToolbarHandle').css({top: handleTop + 'px'});
handleTop = Math.min(handleTop, window.innerHeight - handle.outerHeight() - 10)
handle.css({top: handleTop + 'px'});
}
// Unbind keydown
$(document).unbind('keydown.djDebug');
Expand Down