That's interesting as well.  Though I think you'd run into challenges when 
trying to handle interruptible animations. Specifically you'd have to do 
all the interruptions manually.  This would be even more challenging in the 
context of interruptions that have a delay before they're supposed to 
interrupt.


On Thursday, October 13, 2016 at 2:34:29 PM UTC-4, Zinggi wrote:
>
> I also thought about this problem for a bit.
> I came up with a slightly different solution.
>
> I was not only not happy with storing functions in my model, but also with 
> storing static values in the model (e.g. stuff that wont change often).
> I think it would be nice to separate the *descriptions* of an animation 
> from the *state* of an animation.
>
> So when you actually use an animation, you need to provide an animation 
> description and an animation state, this might look kinda like this:
>
> model =
>   { animationState = Animation.new 0 }
>
> update msg model =
>   case msg of
>     Tick dt ->
>       { model | animationState = Animation.tick dt model.animationState }
>
> animationDescription =
>   { startValue = 0, endValue = 10, speed = 2, easing = Easing.sinInOut, 
> etc... }
>
> view model =
>   animate animationDescription model.animationState
>
>
> On Thursday, 13 October 2016 08:29:19 UTC+2, Aaron VonderHaar wrote:
>>
>> As mentioned in some recent threads [1] [2], easing functions for 
>> animations have been an example of where functions in the model are 
>> currently used.  An alternative approach is to use a union type to indicate 
>> the easing, but a suggested shortcoming of that approach is that there 
>> would then be no way for downstream developers to use their own custom 
>> easings.
>>
>> I was just thinking that this could be achieved as follows:
>>
>> ```
>> type AdvancedEasing a
>>     = Linear | InQuad | OutQuad | ...
>>     | CustomEasing a
>>
>> type alias Easing = AdvancedEasing Never
>>
>> apply : Easing -> Float -> Float
>>
>> applyAdvanced : (a -> Float -> Float) -> AdvancedEasing a -> Float -> 
>> Float
>> ```
>>
>> In this way, the custom easing functions (a -> Float -> Float) are moved 
>> from the model to configuration.
>>
>> I was curious if anyone has experimented with this approach yet.
>>
>>
>> [1]: https://groups.google.com/d/topic/elm-discuss/bOAHwSnklLc/discussion
>> [2]: https://groups.google.com/d/topic/elm-discuss/9qV9iDcv-c8/discussion
>>
>>

-- 
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 elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to