未验证 提交 961412ef 编写于 作者: G GitSquared

Closed #92: Terminal scrolling (touch and mouse)

FINALLY it's starting to get usable
上级 7814e3c1
......@@ -99,6 +99,29 @@ class Terminal {
};
this.socket.onerror = (e) => {throw e};
let parent = document.getElementById(opts.parentId);
parent.addEventListener("wheel", e => {
this.term.scrollLines(Math.round(e.deltaY/10));
});
this._lastTouchY = null;
parent.addEventListener("touchstart", e => {
this._lastTouchY = e.targetTouches[0].screenY;
});
parent.addEventListener("touchmove", e => {
if (this._lastTouchY) {
let y = e.changedTouches[0].screenY;
let deltaY = y - this._lastTouchY;
this._lastTouchY = y;
this.term.scrollLines(-Math.round(deltaY/10));
}
});
parent.addEventListener("touchend", e => {
this._lastTouch = null;
});
parent.addEventListener("touchcancel", e => {
this._lastTouch = null;
});
this.fit = () => {
this.term.fit();
setTimeout(() => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册