Fork me on GitHub
#reagent
<
2020-05-29
>
Spaceman23:05:19

I'm using the framer-motion library to animate a div mount

Spaceman23:05:57

This is what I have:

(:require [framer-motion :refer (motion MagicMotion AnimateSharedLayout AnimatePresence useSpring useMotionValue useTransform useViewportScroll) :as motion])
(def div (.-div motion))

(defn my-component []
    [:> div {
      :initial {:opacity 0}
      :animate {:opacity 1}
      :exit {:opacity 0}} 
"Show Me"])
And a boolean show-my-component? is changed from false to true when I click on a button (I'm using re-frame for managing the boolean show-my-component? but have simplified the code here):
[:button {:on-click (change-show-my-component-boolean-to-true)}]
(if show-my-component? [my-component])

Spaceman23:05:52

But the component doesn't show immediately when clicking the button when using :>div, although it does when using a regular :div, but in the latter case of course there's no animation

Spaceman23:05:00

when using :>div, I have to re-focus or click somewhere on the webpage

Spaceman23:05:12

For my-component to show

Spaceman23:05:16

How do I fix this issue?