Fork me on GitHub
#reagent
<
2019-04-17
>
Bravi00:04:58

for some reason animation option isn’t working. I was wondering if anyone else had this problem. I can see in web developer tools that transform and transition css props are being applied when dragging items, but they are not animated.

Bravi00:04:17

when I try the same exact (minimalistic code) in React, the animation works fine

lilactown00:04:03

what’s the equivalent JS

Bravi00:04:32

React:

<Sortable options={{animation: 150}}>
          {[1, 2, 3].map(item => (
            <li>{item}</li>
          ))}
        </Sortable>
Reagent:
[:> Sortable
   {:options {:animation 150}}
   [:li "hello"]
   [:li "world"]
   [:li "hello some other world"]]

lilactown00:04:59

I think you have to add #js in front of {:animation 150}

lilactown00:04:06

could be wrong. try it out

Bravi00:04:10

still the same

Bravi00:04:35

the weird thing is, as I said - the css props show up in web developer tools

Bravi00:04:47

transition and transform

Bravi00:04:00

but something is still missing

orestis04:04:14

Some global css missing? Lots of libraries assume webpack and import their css.

Bravi08:04:32

I think it’s something to do with shadow-cljs

Bravi08:04:08

because if I load react-sortablejs using CDN and then if I use [:> js/Sortable], it works

thheller08:04:19

@bravilogy if you make a minimal repro I'm happy to take a look at it

Bravi08:04:03

oh that would be amazing 🙂 thank you! I was actually just posting the issue in #shadow-cljs but I’ll create a repo first

Bravi08:04:54

thank you for looking into this

Bravi08:04:40

basically it’s just the animation that doesn’t work

Bravi08:04:47

the sorting bit works

thheller08:04:19

that is indeed very odd

Bravi08:04:16

it is yeah. and the css props do show up

Bravi08:04:30

so technically it should be working

thheller08:04:53

@bravilogy it also works when using

(ns rubaxa.core
  (:require ["sortablejs/Sortable.min.js" :as sortable]
            [reagent.core :as reagent]))

thheller08:04:04

I guess this has something to do with the minification. looking into it.

thheller08:04:16

may just be a bug in sortablejs itself

Bravi08:04:48

oh wow that’s a nice discovery! 😄

Bravi08:04:16

I’m actually fine with using "sortablejs/Sortable.min.js"

thheller09:04:47

yeah its closure. If I just take the Sortable.js and run it through closure (without shadow-cljs) it breaks the same way

Bravi09:04:17

interesting

Bravi09:04:22

thank you so much for your help

Bravi09:04:32

I’ll just use the minified version

Bravi09:04:39

if I wanted to use this react component https://github.com/SortableJS/react-sortablejs which is just a react component that uses that sortablejs library

Bravi09:04:47

how could I fetch that minified version in here?

Bravi09:04:05

I tried "react-sortablejs/react-sortablejs.min.js"

Bravi09:04:09

but that doesn’t work

thheller09:04:49

:resolve {"sortablejs" {:target :require :require "sortablejs/Sortable.min.js"}}

thheller09:04:35

that will rewrite all requires to sortablejs to the minified version. so also the internal require that react-sortablejs has

Bravi09:04:31

oh I see. that’s really cool!

Bravi09:04:56

:js-options {:resolve {"sortablejs" {:target  :require
                                               :require "sortablejs/Sortable.min.js"}}}

Bravi09:04:00

is this correct?

thheller09:04:19

should be yeah

Bravi09:04:02

it’s giving me unknown resolve target

thheller09:04:50

oh sorry .. :target :npm not :target :require

Bravi09:04:21

yaaayyy!! 😄 it all works

Bravi09:04:46

thank you again. I appreciate your help

thheller09:04:37

lets see if they maybe have a clue to whats happening before reporting to closure folks https://github.com/SortableJS/Sortable/issues/1492