-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add scroll functionality for mobile #747
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good start for touch support! Let's move forward with this after the changes are fixed up.
Eventually a nicer solution will be better so that ballistic scroll is properly supported. I just tried it out and it seems to work really well in my branch #748. I'm a little concerned about browser support with the event redirection though so that needs a bunch of verification.
src/Viewport.ts
Outdated
@@ -34,6 +34,7 @@ export class Viewport { | |||
this.terminal.on('scroll', this.syncScrollArea.bind(this)); | |||
this.terminal.on('resize', this.syncScrollArea.bind(this)); | |||
this.viewportElement.addEventListener('scroll', this.onScroll.bind(this)); | |||
this.touchY = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll need to declare this as a private member above to remove the compile warning. A better name might also be lastTouchY
:
private lastTouchY: number;
src/xterm.js
Outdated
if (self.mouseEvents) return; | ||
self.viewport.onTouchStart(ev); | ||
return self.cancel(ev); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing a );
at the end
src/xterm.js
Outdated
if (self.mouseEvents) return; | ||
self.viewport.onTouchMove(ev); | ||
return self.cancel(ev); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing a );
at the end
Thanks for the feedback! I rebased onto the current master branch and also made the changes you asked for. (for some reason, GitHub doesn't seem to recognize my Let me know if there's anything else I should change. |
@anishathalye yeah with GitHub you typically add individual "fix" commits after a PR is made as amending a commit that has already been commented on can turn out a bit weird in GH. The repo owners can squash the commits if they want when it's merged. |
The problem with this is it doesn't support the iOS scroll momentum thing. I've gotten that to work by removing these listeners, using z-index to put the viewport div above the rows div, and putting |
Actually, it turns out that setting the z-index is unnecessary, and not setting the z-index makes selection work. So this is the perfect solution. (For iOS, at least.) |
This patch adds functionality to be able to scroll on mobile (tested with an iOS device).
Part of #594