From 0b4f7c927b48ba5e370a9de76da324d4770b14db Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Fri, 15 Aug 2014 14:09:28 +0200 Subject: [PATCH] Restrict resizing to visible screen This makes sure that the debugbar isn't dragged to high, so the handler is unreachable, and not too low to make sure it's always clear that it's just resized, not broken/collapsed. --- src/DebugBar/Resources/debugbar.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/DebugBar/Resources/debugbar.js b/src/DebugBar/Resources/debugbar.js index 23cf5ce..73bee1d 100644 --- a/src/DebugBar/Resources/debugbar.js +++ b/src/DebugBar/Resources/debugbar.js @@ -461,6 +461,8 @@ if (typeof(PhpDebugBar) == 'undefined') { // dragging of resize handle var dragging = false; + var min_h = 40; + var max_h = $(window).height() - this.$header.height() - 10; this.$resizehdle.on('mousedown', function(e) { var orig_h = $body.height(), pos_y = e.pageY; dragging = true; @@ -468,6 +470,9 @@ if (typeof(PhpDebugBar) == 'undefined') { $body.parents().on('mousemove', function(e) { if (dragging) { var h = orig_h + (pos_y - e.pageY); + // Respect the min/max values + h = Math.min(h, max_h); + h = Math.max(h, min_h); $body.css('height', h); localStorage.setItem('phpdebugbar-height', h); self.recomputeBottomOffset();