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

entry.intersectionRatio is not exactly 1.0 #3085

Closed
aminya opened this issue Sep 9, 2020 · 9 comments · Fixed by #3088
Closed

entry.intersectionRatio is not exactly 1.0 #3085

aminya opened this issue Sep 9, 2020 · 9 comments · Fixed by #3088
Labels
type/question A question on how to use the library

Comments

@aminya
Copy link

aminya commented Sep 9, 2020

Details

  • Browser and browser version: Electron 6
  • OS version: Win 10
  • xterm.js version: 4.9.0

Steps to reproduce

We hit a strange bug that was blocking us for a couple of days. Until we found the intersectionRatio is sometimes near to 1.0 (like 0.99) but not exactly 1.0.

atom-community/terminal#5 (comment)
atom-community/terminal#5

I just wanted to let you know about this behavior.

We had a condition to create xterm Element only if intersectionRatio === 1.0 which was not being triggered (this condition was to avoid bus-stop/x-terminal#57).

Suggestion

Introduce a boolean value that shows if the intersectionRatio is almost 1.

@UziTech
Copy link
Contributor

UziTech commented Sep 9, 2020

This is probably a bug in chrome not xterm.

@aminya
Copy link
Author

aminya commented Sep 9, 2020

Where can we report this bug? Should it be chromium? https://chromium.googlesource.com/chromium/src/

@aminya
Copy link
Author

aminya commented Sep 9, 2020

There seems to exist a isIntersecting property:

this._isPaused = entry.isIntersecting === undefined ? (entry.intersectionRatio === 0) : !entry.isIntersecting;

But seems to have its own issues: #2998 (comment)

@Tyriar
Copy link
Member

Tyriar commented Sep 9, 2020

Looks like you've already fixed it, no?

atom-community/terminal@7a05451

We only care if it's partially visible (entry.intersectionRatio === 0):

this._isPaused = entry.isIntersecting === undefined ? (entry.intersectionRatio === 0) : !entry.isIntersecting;

@Tyriar Tyriar closed this as completed Sep 9, 2020
@Tyriar Tyriar added the type/question A question on how to use the library label Sep 9, 2020
@aminya
Copy link
Author

aminya commented Sep 9, 2020

We solved it by a workaround, but this is a xterm issue. xterm should not allow the following error:
bus-stop/x-terminal#57 (comment)

@UziTech
Copy link
Contributor

UziTech commented Sep 9, 2020

That error comes from the fit addon. Running fit when the canvas that has a 0 width or height will throw the error Uncaught Error: This API only accepts integers

@Tyriar
Copy link
Member

Tyriar commented Sep 10, 2020

We could handle that better but in the end the right behavior is probably still throw, just with a better message about NaN terminal dimensions.

@UziTech
Copy link
Contributor

UziTech commented Sep 10, 2020

I feel like fit being called on a hidden element or one with 0 width or height shouldn't throw an error. It should just check for that situation and return early without doing anything. I can't see a situation where that would be a problem.

@UziTech
Copy link
Contributor

UziTech commented Sep 10, 2020

It already seems to do something similar if the terminal isn't connected to the dom

if (!dims || !this._terminal) {
return;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/question A question on how to use the library
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants