Skip to content
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

Auto scroll not working when viewport height is set #934

Closed
twifty opened this issue Sep 2, 2017 · 5 comments
Closed

Auto scroll not working when viewport height is set #934

twifty opened this issue Sep 2, 2017 · 5 comments

Comments

@twifty
Copy link

twifty commented Sep 2, 2017

Details

  • Browser and browser version: Chrome/Atom 1.18
  • OS version: Manjaro
  • xterm.js version: 2.9.2

Steps to reproduce

I'm trying to remove the half line gap below the viewport as described in #762. My method is to set the height on the viewport after an element resize event:

this.resizeObserver = new ResizeObserver(() => {
      this.terminal.fit()
      // fix the half row gap at bottom of terminal
      this.terminal.viewportElement.style.height = this.refs.xterm.clientHeight + 'px'
});
this.resizeObserver.observe(this.refs.xterm);

While this works, the side affect is when calling Terminal.write it no longer auto scrolls to the bottom.

Is there anything I can do to get the desired behaviour?

@Tyriar
Copy link
Member

Tyriar commented Sep 2, 2017

If you touch viewportElement, you're gonna have a bad time 😄

In VS Code I align the terminal to the bottom, rather than the top, that makes the padding move to the top which is less noticeable.

@twifty
Copy link
Author

twifty commented Sep 2, 2017

I figured as much. I'm also trying to align to the bottom but I can't for the life of me figure it out.

Due to the resizable nature of the panel, I have specified flex-grow: 1 on the outer container. Nothing I have tried so far (barring relative and absolute) will move the terminal bound element.

@twifty twifty closed this as completed Sep 2, 2017
@Tyriar
Copy link
Member

Tyriar commented Sep 2, 2017

@twifty you can check this file out for what VS Code does https://github.com/Microsoft/vscode/blob/465c3ed79335a971cbce040f003d205a4c141e15/src/vs/workbench/parts/terminal/electron-browser/media/terminal.css#L44

There's some flexbox as well as absolute positioning to the bottom, can't remember the exact reason for that.

@Tyriar
Copy link
Member

Tyriar commented Sep 2, 2017

Good luck 😃

@twifty
Copy link
Author

twifty commented Sep 2, 2017

Thanks, I finally figured it out though. Nested flexboxes. I had to display: flex on the terminal element then margin-top: auto on the viewport.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants