Merge branch 'master' into 751-IE11-demo

This commit is contained in:
Paris Kasidiaris
2017-07-04 12:50:37 +03:00
committed by GitHub
2 changed files with 39 additions and 0 deletions
+23
View File
@@ -13,6 +13,7 @@ export class Viewport {
private currentRowHeight: number;
private lastRecordedBufferLength: number;
private lastRecordedViewportHeight: number;
private lastTouchY: number;
/**
* Creates a new Viewport.
@@ -121,4 +122,26 @@ export class Viewport {
// Prevent the page from scrolling when the terminal scrolls
ev.preventDefault();
};
/**
* Handles the touchstart event, recording the touch occurred.
* @param ev The touch event.
*/
public onTouchStart(ev: TouchEvent) {
this.lastTouchY = ev.touches[0].pageY;
};
/**
* Handles the touchmove event, scrolling the viewport if the position shifted.
* @param ev The touch event.
*/
public onTouchMove(ev: TouchEvent) {
let deltaY = this.lastTouchY - ev.touches[0].pageY;
this.lastTouchY = ev.touches[0].pageY;
if (deltaY === 0) {
return;
}
this.viewportElement.scrollTop += deltaY;
ev.preventDefault();
};
}
+16
View File
@@ -1095,6 +1095,18 @@ Terminal.prototype.bindMouse = function() {
self.viewport.onWheel(ev);
return self.cancel(ev);
});
on(el, 'touchstart', function(ev) {
if (self.mouseEvents) return;
self.viewport.onTouchStart(ev);
return self.cancel(ev);
});
on(el, 'touchmove', function(ev) {
if (self.mouseEvents) return;
self.viewport.onTouchMove(ev);
return self.cancel(ev);
});
};
/**
@@ -1915,6 +1927,10 @@ Terminal.prototype.resize = function(x, y) {
return;
}
if (y > this.getOption('scrollback')) {
this.setOption('scrollback', y)
}
var line
, el
, i