Last active
May 6, 2016 21:46
-
-
Save jwmerrill/a4910284ca071a932f60c4cdcbccad88 to your computer and use it in GitHub Desktop.
Updated version of Elm's resizable yogi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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