In your `Animate animMsg` area, you're not returning the cmds, which is how 
the msg is fired :).

Change your code to this:

Animate animMsg ->
      let 
        (newStyle, cmds) = 
          Animation.Messenger.update
            animMsg
            model.storyTextStyle
      in
     ( { model
            | storyTextStyle = newStyle
       }
     , cmds
    )



On Monday, October 3, 2016 at 2:09:57 PM UTC-4, Rex van der Spuy wrote:
>
> Thanks everyone, I like these ideas!
>
> Here's what I've got so far - but it's not working... yet! :) 
> Could any of you with more experience with elm-style-animation let me know 
> what I'm doing wrong?
>
> I've imported Animation and Animation.Messener, exposing State:
>
> ```
> import Animation
> import Animation.Messenger exposing (State)
> ```
>
> I created a style for my text called `storyTextStyle`
>
> ```
>  , storyTextStyle : Animation.Messenger.State Msg
>
> , storyTextStyle = 
>       Animation.style
>         [ Animation.opacity 1.0
>         ]
>
> ```
> I added it to the view, which displays my story output text
>
> ```
> div [ storyCardStyle ] 
>             [ p ( Animation.render model.storyTextStyle ++ [ 
> storyParagraphStyle ]) [ text model.storyOutput ] ]
> ```
>
> I have an MDL button that triggers a `FadeInOut` update message:
>
> ```
> , Button.onClick FadeInOut
> ```
>
> The `FadeInOut` message and `Animate` message are in the `update` function:
>
> ``` 
> Animate animMsg ->
>       let 
>         (newStyle, cmds) = 
>           Animation.Messenger.update
>             animMsg
>             model.storyTextStyle
>       in
>      { model
>          | storyTextStyle = newStyle
>      }
>      ! [ ]
>
>     FadeInOut -> 
>       let
>         newStyle =
>           Animation.interrupt
>             [ Animation.to [Animation.opacity 0]
>             , Animation.Messenger.send SendStoryComponents
>             , Animation.to [Animation.opacity 1]
>             ]
>             model.storyTextStyle
>       in
>       { model
>           | storyTextStyle = newStyle
>       }
>       ! [ ]
> ```
>
> ... all this compiles and I've tested `FadeInOut` with Debug.crash to make 
> sure it's called - and it is definitely being called when I click the 
> button.
> But, my `SendStoryComponents`, which generates the new text to fade is, is 
> never called.
> Here's `SendStoryComponents` (it uses a port that does some fun stuff with 
> nlp-compromise.js to generate a random story based on user input and story 
> templates)
>
> ```
> SendStoryComponents ->
>       let
>         words = 
>           model.words
>
>         toList string =
>           String.Extra.clean string
>           |> String.split " "
>
>
>         words' =
>           { places = toList model.places 
>           , livingThings = toList model.livingThings
>           , objects = toList model.objects
>           , actions = toList model.actions
>           , moods = toList model.moods
>           }
>
>         model' =
>           { model 
>               | words = words'
>           }
>       in
>       (model', sendStoryComponents(model'.words, StoryTemplates.stories))
> ```
> (`SendStoryComponents` does work, if I don't call it through the 
> `FadeInOut` message.)
>
> Can anyone tell by looking at that why `Animation.Messenger.send` might 
> not be calling `SendStoryComponents` ?
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to