• Stars
    star
    131
  • Rank 275,867 (Top 6 %)
  • Language
    Elm
  • License
    BSD 3-Clause "New...
  • Created about 5 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A timeline-based animation engine for Elm

Elm Animator

Bring animations to your Elm app!

Check out the talk that goes with the library, The Immutable Animator's Toolkit.

Join the #animations channel on the Elm Slack if you want to chat!

Animating with Timelines

The high level idea is to track timelines of values in your model and animate between them.

So, if you were previously storing a Bool, now you'd store Animator.Timeline Bool, and you'd be able to animate the state transitions in your view

    div
        [ Animator.Inline.opacity model.checked <|
            \checked ->
                if checked then
                   Animator.at 1

                else
                   Animator.at 0
        ]
        [ text "๐Ÿ‘" ]

This library handles the animation for you! (There is slightly more work to do to get started so start with the Checkbox example)

This approach is pretty cool! It allows you to:

  • Model your animations in terms of the Model you're already storing
  • Animate any number of elements while only tracking one timeline. This is fantastic for rich animations that need to coordinate several components.

This library also has the ability to dynamically generate CSS @keyframes, which means your animations can be very performant.

Let's check out some examples!

Overview of examples

Note if you clone this library to play with the code locally, make sure to cd examples and run elm make from there!

  1. Checkbox (live example) โ€” Animate a checkbox as it's checked. It covers:

    • How to get started with elm-animator
    • An idea of how to incrementally upgrade existing code to use animations
  2. Page transitions (live example) โ€” Transition between pages 3d page transition with routing.

    • Set up routing so there are no page reloads (actually this is standard for SPAs in general).
    • Animate the transition between pages
    • How to do CSS Keyframe generation
  3. Loading (live example) โ€”Animate the loading state of a piece of content.

    • How to animate resting states such as a loading spinner
    • Animate with content that's already been deleted (whaaaa?!)
  4. Mario (live example)โ€” The classic Mario example! Run around and jump.

    • How to get started with sprite animation
    • How to interact with a separate animation system such as physics code!

The Goal of a Continuous UI

Animation can either be a nuanced, playful helper in your UI, or it can be a nuisance.

There's an immediate question of what kinds of animation we want to cultivate in the Elm community.

With that in mind, here are two types of animation that I'd love to emphasize and elm-animator should be very useful for both.

Continuous UI

A continuous UI minimizes context-shifting for a user and allows them to build a spatial model of your interface.

We're generally used to pieces of UI popping in and out of existence, and pages that change drastically on click. Everytime something changes, it's a context shift for your user.

We can use animation to make that experience continuous so our users can build a quick intuition about how our interfaces work.

Sarah Drasner has an excellent talk showing what a continuous UI interaction can look like.

There's also a fairly basic page transition example - (Code) for this library that has the same principle.

Calm Enrichment

The second type is something I think of as calm enrichment.

The floating city on the Elm Japan Website โ€”you will need to scroll down a littleโ€” is wonderful!

It doesn't distract from what I'm trying to accomplish on the website, it simply sits there, calmly floating. It doesn't take anything away from my budget of attention that I have when visiting the website. In fact it likely increases the amount of attention I'm willing to pay.

They used elm-playground โ€”which I am likewise inspired byโ€” to achieve the effect and convinced me to make this sort of thing easy in elm-animator.

More Repositories

1

elm-ui

What if you never had to write CSS again?
Elm
1,322
star
2

style-elements

Create styles that don't mysteriously break!
HTML
446
star
3

elm-style-animation

The style animation library for Elm!
Elm
444
star
4

elm-markup

Elm-friendly markup
Elm
177
star
5

elm-codegen

Elm
137
star
6

elm-optimize-level-2

Elm
128
star
7

stylish-elephants

This project has matured and been released! Go here ->
Elm
44
star
8

elm-animation-flower-menu

JavaScript
17
star
9

design-discussion-elm-ui-2

A repo for discussing changes to Elm UI 2
17
star
10

elm-dev

Haskell
17
star
11

atom-inline-messenger

Inline Messaging in the Atom Editor
CoffeeScript
14
star
12

mechanical-elephant-hakyll

mechanical-elephant.com
CSS
11
star
13

elm-color-mixing

Color mixing in elm!
Elm
9
star
14

elm-markup-cli

JavaScript
9
star
15

elm-skimmer

Browse elm packages and projects with metrics!
HTML
8
star
16

style-elements-design-discussion

8
star
17

elm-animation-pack

Easily manage your animation states in Elm!
Elm
6
star
18

elm-markup-vscode

Syntax Highlighting for .up files for `elm-markup`
JavaScript
6
star
19

Elmsmith

A Static Site Generator in Elm
HTML
5
star
20

kubernetes-starterkit

WARNING: not for use quite yet.
Python
5
star
21

elm-prefab

Maintainable code generation for Elm Apps
JavaScript
5
star
22

ui-animation

All Work from this Repo has been published at https://github.com/mdgriffith/elm-style-animation
Elm
5
star
23

elm-gql-github-example

An example repo for elm-gql that uses the Github GraphQL API
Elm
4
star
24

low-poly-background

CoffeeScript
4
star
25

drakon-anywhere

The Drakon Editor in a Docker container so it can run anywhere
Shell
4
star
26

elm-html-animation

DEPRECATED: Use https://github.com/mdgriffith/elm-style-animation if you're on elm 0.17
Elm
4
star
27

elm-path

UNDER CONSTRUCTION! Just a sketch at the moment :)
HTML
4
star
28

roam-notion-import

A script to help import files from notion to roam research
Rust
3
star
29

elm-debug-watch

Convenience functions to log the input and output of a function.
Elm
3
star
30

elm-color

Elm
3
star
31

elm-animation-talk

JavaScript
2
star
32

elm-all-docs

A cache of all the docs.json files on the Elm Package website
TypeScript
2
star
33

roc-tui

CSS
2
star
34

site-selfie

Haskell
1
star
35

elm-style-elements-simple-example

DEPRECATED (This repo uses a much older version of style-elements)
Elm
1
star
36

elm-style-elements-complex-example

DEPRECATED (This repo uses a much older version of style-elements)
HTML
1
star
37

language-guitar-tab

Syntax Highlighter for Guitar Tablature for the Atom Code Editor
CoffeeScript
1
star
38

elm-style-animation-zero-sixteen

elm-style-animation for elm 0.16 (This is generally deprecated, use elm-style-animation for elm 0.17 and above)
Elm
1
star
39

elm-ui-testing

A repo for tracking elm-ui testing results
HTML
1
star