mirror of
https://github.com/simon987/Much-Assembly-Required-Frontend.git
synced 2025-04-19 18:46:41 +00:00
Fixed a bit of scrolling. Now you don't get jumped around the page.
This commit is contained in:
parent
c35db10441
commit
b75ba708d8
@ -887,16 +887,20 @@ terminal.height = 8;
|
|||||||
terminal.fontsize = 10; // In tenths of em
|
terminal.fontsize = 10; // In tenths of em
|
||||||
|
|
||||||
terminal.scroll_update = function() {
|
terminal.scroll_update = function() {
|
||||||
terminal.elem.style.marginTop = (terminal.scroll * -1.1) + "em";
|
var old = terminal.scroll;
|
||||||
}
|
|
||||||
|
|
||||||
terminal.scroll_handler = function(wheel_event) {
|
|
||||||
terminal.scroll += (Math.abs(wheel_event.deltaY) / wheel_event.deltaY);
|
|
||||||
terminal.scroll = Math.max(Math.min(
|
terminal.scroll = Math.max(Math.min(
|
||||||
Math.max(terminal.scroll, 0),
|
Math.max(terminal.scroll, 0),
|
||||||
terminal.elem.childElementCount - terminal.height
|
terminal.elem.childElementCount - terminal.height
|
||||||
), 0);
|
), 0);
|
||||||
terminal.scroll_update();
|
terminal.elem.style.marginTop = (terminal.scroll * -1.1) + "em";
|
||||||
|
return terminal.scroll - old; // Actually it is always 0 on successful scroll. On edges it's +-1
|
||||||
|
}
|
||||||
|
|
||||||
|
terminal.scroll_handler = function(wheel_event) {
|
||||||
|
terminal.scroll += (Math.abs(wheel_event.deltaY) / wheel_event.deltaY);
|
||||||
|
if (terminal.scroll_update() == 0) {
|
||||||
|
wheel_event.preventDefault();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
terminal.add_line = function(text) {
|
terminal.add_line = function(text) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user