New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Images mixing #132

Closed
jastice opened this Issue Jan 23, 2015 · 2 comments

Comments

Projects
None yet
2 participants
@jastice

jastice commented Jan 23, 2015

Not sure if this is a compiler or core library issue or programming error, I haven't identified the cause yet, but it seems like it shouldn't happen due to programming error. Also I have a hard time finding a good description, but when running the example code (a simple slide-like presentation) below, this is what I observe:

  • when going from the second slide (shell) to the third (book), the image dimensions get replaced with those of the third slide, but the image stays the same.
  • going forward, then back again, will correctly show the book
  • this happens only when an image is followed by a fittedImage, when both are regular or fitted image, they show up as expected

Also worth noting: This setup somehow breaks hot reloading in elm-reactor. When changing something, often I have to manually reload for everthing to work.

(using Elm platform 0.16)

module Bugs where

import List exposing ((::), foldr, length, drop, head)
import Signal exposing (Signal, constant, foldp, map2)
import Graphics.Element exposing (..)
import Keyboard
import Debug
import Text exposing (fromString)


slides = [
  constant <| centered <| fromString "use arrow keys to go forward/backward",
  constant <| fittedImage 100 500 "https://raw.githubusercontent.com/elm-lang/elm-lang.org/master/resources/imgs/shells.jpg",
  constant <| image 700 500 "https://raw.githubusercontent.com/elm-lang/elm-lang.org/master/resources/imgs/book.jpg",
  constant <| centered <| fromString "go back and it will be a book instead of shells"
  ]

lastSlide = length slides - 1

updateSlide {x,y} current = 
  let nextSlide = case x of
        -1 -> current - 1
        1 -> current + 1
        _ -> current
  in clamp 0 lastSlide nextSlide 

chooseSlide page = drop page >> head

safeSlide e = case e of
  Just elem -> elem
  Nothing -> centered <| fromString ""

-- signals

currentSlide = foldp updateSlide 0 Keyboard.arrows

main = 
  let maybeSlides = applyMany (Signal.map chooseSlide currentSlide) slides
  in Signal.map safeSlide maybeSlides


-- debug
slideWatch = Signal.map (Debug.watch "slide") currentSlide


-- taken from elm-signal-extra

combine : List (Signal a) -> Signal (List a)
combine = foldr (map2 (::)) (constant [])

andMap : Signal (a -> b) -> Signal a -> Signal b
andMap = map2 (<|)

applyMany : Signal (List a -> b) -> List (Signal a) -> Signal b
applyMany fs l = andMap fs (combine l)
@jastice

This comment has been minimized.

Show comment
Hide comment
@jastice

jastice Nov 29, 2015

Confirmed same behavior for 0.16, and updated example code.

jastice commented Nov 29, 2015

Confirmed same behavior for 0.16, and updated example code.

@evancz

This comment has been minimized.

Show comment
Hide comment
@evancz

evancz May 11, 2016

Member

Sorry this did not get attention til now! The Graphics.* modules now live in evancz/elm-graphics so I am trying to get stuff migrated over there. I'm hoping this will make it easier to get help on stuff like this!

Member

evancz commented May 11, 2016

Sorry this did not get attention til now! The Graphics.* modules now live in evancz/elm-graphics so I am trying to get stuff migrated over there. I'm hoping this will make it easier to get help on stuff like this!

@evancz evancz closed this May 11, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment