reagent

A minimalistic ClojureScript interface to React.js http://reagent-project.github.io/
Spaceman 2020-06-02T00:32:49.054300Z

@jcb that's still doesn't work unfortunately. The animation does work, but I still have to click twice or re-focus on the webpage for it to occur. What should I do to get help?

awb99 2020-06-02T05:29:15.056600Z

I have a question on reagent performance for large svg drawings (which contain 100s or 1000s of sub nodes): Is the vdom-dom rendering much slower than pure HTML in such cases?

jcb 2020-06-02T11:30:17.062Z

@pshar10 at this point, probably worth putting together a simplified gist so people can test it themselves. Have you had plain css or React Css Transition Group animations working? they all work in basically the same way

2020-06-02T13:15:21.062300Z

Hi @pshar10 sorry i was off

2020-06-02T13:15:49.062500Z

Here a sample of code that works and show how to. use animate-presence

(defn my-comp
  []
  (r/with-let
   [clicked (r/atom false)]
   [:<>
    [:div {:on-click #(swap! clicked not)}
     "click me"]
    [:> motion/animate-presence
     (if @clicked
       [:> motion/div
        {:key :my-comp
         :class [:my-comp]
         :variants {:initial {:opacity 0
                              :y 100
                              :x 0
                              :scale 1}
                    :animate {:opacity 1
                              :y 0
                              :scale 1}
                    :exit {:opacity 0
                           :x 100
                           :scale 0.2}}
         :initial :initial
         :animate :animate
         :exit :exit}
        "my-comp"])]]))

2020-06-02T13:16:23.062700Z

The key part is important and should be. different for each componentthat use motion

2020-06-02T13:27:11.062900Z

Here is the same example without if and with a different key based on an atom

2020-06-02T13:27:32.063100Z

(defn my-comp
  []
  (r/with-let
   [clicked (r/atom false)]
   [:<>
    [:div {:on-click #(swap! clicked not)}
     "click me"]
    [:> motion/animate-presence
     [:> motion/div
      {:key (str :my-comp @clicked)
       :class [:my-comp]
       :variants {:initial {:opacity 0
                            :y 100
                            :x 0
                            :scale 1}
                  :animate {:opacity 1
                            :y 0
                            :scale 1}
                  :exit {:opacity 0
                         :x 100
                         :scale 0.2}}
       :initial :initial
       :animate :animate
       :exit :exit}
      (str "my-comp" @clicked)]]]))

2020-06-02T13:27:50.063300Z

r/with-let is reagent/with-let