Skip to content

Commit

Permalink
Lock scroll bottom on console window resize. Fixes #32.
Browse files Browse the repository at this point in the history
On resizer mousedown, save the current scroll position. On resizer mousemove
calculate the change and adjust the scroll position. This allows the current
scroll position to lock to the bottom of the screen when rezizing the console
window. Tested on the latest chrome, firefox and safari.
  • Loading branch information
noahpatterson committed Jan 31, 2015
1 parent ed7b20b commit ad33d17
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/web_console/templates/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,15 @@ REPLConsole.prototype.install = function(container) {

// Make the console resizable.
document.getElementById('resizer').addEventListener('mousedown', function(ev) {
var startY = ev.clientY;
var startHeight = parseInt(document.defaultView.getComputedStyle(container).height, 10);
var startY = ev.clientY;
var startHeight = parseInt(document.defaultView.getComputedStyle(container).height, 10);
var consoleInner = document.getElementsByClassName('console-inner')[0];
var innerScrollTopStart = consoleInner.scrollTop;
var innerClientHeightStart = consoleInner.clientHeight;

var doDrag = function(e) {
container.style.height = (startHeight + startY - e.clientY) + 'px';
consoleInner.scrollTop = innerScrollTopStart + (innerClientHeightStart - consoleInner.clientHeight);
};

var stopDrag = function(e) {
Expand Down

0 comments on commit ad33d17

Please sign in to comment.