Hey guys- I built an app with peer to peer chat, but I need the chat window which uses a vertical scrolling repeating group to automatically scroll down when new chats/messages come in.
Right now it auto pulls up to the top, and if new messages are sent it scrolls up a tad.
I have created a peer-to-peer messaging system as well. I am able to get my repeating group of messages to scroll to the ālast itemā upon page load (or reload) and when a āsend messageā button is clicked from the same page. See image:
But how I can set up an event listener to scroll to the ālast itemā when a new message is added to the repeating group of messages remotely (by another user)?
Ok, in answer to my own question āBut how I can set up an event listener to scroll to the ālast itemā when a new message is added to the repeating group of messages remotely (by another user)?ā
This is looking like it works:
Create a custom state attached to the repeating group of messages. Custom state should be a number. It will track the ācountā of messages in the chatbox (aka repeating group of messages)
Create a workflow event that fires when page is loaded (Click here to add an event⦠> General > Page is loaded). It should (1) scroll to ālast itemā of chatbox, then (2) set the custom state described above to number of messages in the chatbox.
Create another workflow event (Click here to add an event⦠> General > Do when condition is true). Edit the āOnly whenā setting to fire only when the ācountā of the chatbox (aka the repeating groupās messages count) is greater than custom stateās count (aka when another message is added to the conversation). There are 2 steps in this workflow event: (1) scroll to ālast itemā of repeating group and (2) set state to (newly updated) ācountā of messages.