Fork me on GitHub
#re-frame
<
2019-10-02
>
mccraigmccraig20:10:18

i need to choose whether to render a component based on the position of the visible area in a scroll region - how have people achieved this ? processing scroll events to only produce a re-frame event when scrolling stops/pauses for a period seems like one possibility (previously we've had problems with the frequency of scroll events killing performance on mobile devices if turned directly into re-frame events). are there any others i'm missing ?

isak21:10:49

@mccraigmccraig you could debounce the firing of those events to limit the perf problem

isak21:10:12

At my work we did it by making a higher-order-component where the tooltips render function gets the tooltipee's DOM element as an argument to it's render function. It can then do measurements to decide its position. This also requires listening to window-size (debounced for perf)

👍 8