Skip to content

Conversation

@coderaiser
Copy link
Contributor

IntersectionObserver can produce more than 1 entry, and latest is the most true, then first.

I'm using xterm.js in Cloud Commander as gritty middleware in a modal window. And I have a bug which is reproduced in the latest version of chrome but not in firefox. The thing is firefox shows modal with a terminal and output information because it has exactly one entry, and chrome has two entries, and second has intersectionRatio=1, but first has intersectionRatio=0 so it shows empty screen.(coderaiser/cloudcmd#214).

Copy link
Member

@Tyriar Tyriar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@coderaiser I thought that it would only include multiple entries if multiple objects were being observed? I'm concerned the fix might break other browsers, do you know what each entry represents and if their order is guaranteed? Should we be iterating through the list instead?

@coderaiser
Copy link
Contributor Author

coderaiser commented Feb 5, 2019

@Tyriar It is always returns an array, so it is definitely should be iterated. You can look at scroll example on the the link above: when the element you observing appears intersectionRatio becomes 1 and you can see percents change.

It should not brake other browsers (then chrome and firefox), because it relates only on output of information to terminal, so the reasoning is when terminal is loading - output nothing, finished loading - show everything.

In any case, last IntersectionObserverEntry is an actual result, all of them has time property, so last one has a bigger time, so it is what most closely is going on to current moment of a thing you observing. Here is output example I just received:

time: 11242.52499999966 // first entry
time: 11267.78000000013 // second entry

So the order is definitely guaranteed.

And main difference of how it was before: you observed an older entry, which has lower time, and which is already done in the past so the terminal window in the modal of Cloud Commander is empty and needs restart.

If behavior I'm talking about is inappropriate would be great to make using IntersectionObserver optional so I do not need to remove it from window to avoid detection, maybe other libraries also depend on it.

@Tyriar Tyriar added this to the 3.12.0 milestone Mar 4, 2019
@Tyriar Tyriar self-assigned this Mar 4, 2019
Copy link
Member

@Tyriar Tyriar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cheers! Sorry about the delay, should land in 3.12.0 👍

@Tyriar Tyriar merged commit d8b973b into xtermjs:master Mar 4, 2019
coderaiser added a commit to coderaiser/cloudcmd that referenced this pull request Mar 14, 2019
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

Successfully merging this pull request may close these issues.

2 participants