Last active
February 28, 2016 13:46
-
-
Save lorenzo/1c7ab68988f659f4e84a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
port autoScroll : Signal () | |
port autoScroll = Signal.map (always ()) scrollMailbox.signal | |
scrollMailbox : Signal.Mailbox Action | |
scrollMailbox = Signal.mailbox FromEffect | |
{- configuration for the start app -} | |
config : StartApp.Config Model Action | |
config = | |
{ init = (initialModel, initialEffect) | |
, update = update | |
, view = view | |
, inputs = [ {- Some more signals here -}, scrollMailbox.signal] {- Added the last one -} | |
} | |
update action model = | |
case action of | |
NewMessages items -> | |
( | |
{ model | items = items } | |
, Signal.send scrollMailbox.address NoOp |> kickOff {- kickoff converts the taks to an effect of the right type -} | |
) |
This file contains hidden or 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
<script> | |
chat.ports.autoScroll.subscribe(function (event) { | |
var div = document.getElementsByClassName('chat-history')[0]; | |
div.scrollTop = div.scrollHeight | |
}); | |
<script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment