Today my colleague was implementing an interesting feature. This is a tree widget feature where a node is dragged on to the other node. The collapsed node would autoexpand if the drag hover exceeds a certain period of time.
The asynchronous operations are tricky. Here there are multiple hover events are emitted on hovering on a node.
The psuedo code solution for this problem
- On hover set a Timeout and save the timeout variable and the domNode in outerscope.
- If there are mutiple hovers on the same node then the timeout should not be set again
- If there is a hover on differnt node then we have to clear the timeout and again start the timeout.
I am trying to find any other way we could fix this problem. In CSS there is animation we could control to apply after certain period of time, we could use this solve this issue.