Last active
June 7, 2018 22:29
-
-
Save paultopia/e67da7899cdf52a677169de0edcd5d87 to your computer and use it in GitHub Desktop.
Floating navbar with only a single css property changed (thanks to the magic of reagent, a clojurescript interface to react)
Looks simple, already playing with it :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is an insane hack to avoid writing CSS. Uses reagent to implement a floating top navbar from scratch without changing more than a single CSS property. The strategy is just to hook an event listener on scroll that updates a ratom containing the y-axis position, and then make the position property of the div containing the navbar depend on that.
Which is nutty, and makes the navbar appear to jump around a teensy bit, but is so so so so much nicer than having to fight with css to get the elements under the navbar positioned correctly with respect to it.