Skip to content

Instantly share code, notes, and snippets.

@jwmerrill
Last active May 6, 2016 21:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jwmerrill/a4910284ca071a932f60c4cdcbccad88 to your computer and use it in GitHub Desktop.
Save jwmerrill/a4910284ca071a932f60c4cdcbccad88 to your computer and use it in GitHub Desktop.
Updated version of Elm's resizable yogi
import Html exposing (..)
import Html.App as Html
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import Mouse
main =
Html.program
{ init = (Model 200, Cmd.none)
, view = view
, update = update
, subscriptions = subscriptions
}
-- MODEL
type alias Model =
{ size: Int
}
-- UPDATE
type Msg
= MouseMove Mouse.Position
update : Msg -> Model -> (Model, Cmd Msg)
update action model =
case action of
MouseMove p ->
(Model (Basics.max p.x p.y), Cmd.none)
-- VIEW
view : Model -> Html Msg
view model =
img [
src "/imgs/yogi.jpg",
width model.size,
height model.size
] []
-- SUBSCRIPTIONS
subscriptions : Model -> Sub Msg
subscriptions model =
Mouse.moves MouseMove
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment