Fork me on GitHub
#rum
<
2017-08-30
>
pez07:08:26

Two newbie questions regarding client side rum. Both because I need to make a an element on the page sticky when scrolled to the top of the page. (Very similar to the search bar here: https://codepen.io/chriscoyier/pen/AdaKr ) …

pez07:08:17

Q1. My current solution uses the same technique as that code pen does. Installing a listener on the scroll event and changing a class on the sticky element when the scroll value equals the top position of the element on the page. Installing the listener is the problem for me. Currently I do it inside the component hiccup when the client app has started. Leaving an empty [:span] element as the “result” of the code. Like so

[:div#my-sticky-container
   #?(:cljs
      (do
        (when should-listener-install?
          (sticky/install-listener "my-sticky"))
        [:span]))
I’m memoizing the function to make sure the listener only install once. This works, but I think there should be a better way to install a listener like that. How would you do it?

pez07:08:24

Q2: The current solution seems a bit like forcing a foreign paradigm onto Rum and React. Is there a more Rum “native” way to do it?

pepe10:08:06

@martinklepsch for managing state I am very happy with https://github.com/funcool/potok I was just thinking how to add derivates into the mix, but in this phase of my project I am quite happy with rum/cursor 🙂.

pez14:08:12

Hmmm, sorry for that guys, I didn’t know things where crossposted here. I tried to do the right thing! 😀 (And now it crossposted this to Gitter as well.)