krzema12 / hypergravity

Gravity simulation in Hyper terminal
MIT License
23 stars 5 forks source link

Some elements are not animated #13

Closed krzema12 closed 6 years ago

krzema12 commented 6 years ago

Tested in Windows 8.1 and Ubuntu 16.04. Its because some parts of the text are not wrapped in any HTML tag. The reason why the terminal content is formated differently on various operating systems is unknown.

A quick fix may be to take the whole row nodes. Another idea is to post-process the chosen nodes so that they are wrapped in some span elements or something.

krzema12 commented 6 years ago

The basic cause for this bug is not taking text nodes into account. It's because children instead of childNodes is used when getting child nodes of some node.

childNodes includes all child nodes, including non-element nodes like text and comment nodes. To get a collection of only elements, use ParentNode.children instead.

(https://developer.mozilla.org/en-US/docs/Web/API/Node/childNodes)

The step forward is to used childNodes and properly clone and animate text nodes.

krzema12 commented 6 years ago

Proof of concept of the above idea pushed on a temporary branch: https://github.com/krzema12/hypergravity/tree/wip-fix-for-not-all-elements

krzema12 commented 6 years ago

Confirmed it works on Windows and Linux.