0

I have an Angular ng-repeat in scrollable div (chat window). On init it is glued to bottom, but when I scroll it to top it loads old messages from history. My problem is when I scroll to top, it adds new messages and staying on the top, which triggers load of a new heap of data e.t.c. What I want is to stay on the same position after new messages adds above.

The only solution I can imagine - to check height of chat before insertion and after insertion. And scroll top by the difference. Maybe there is a better solution?

Kindzoku
  • 1,368
  • 1
  • 10
  • 29
  • Without providing a minimal code it's hard to help. – Endre Simo Jul 11 '16 at 06:51
  • @SimoEndre, I just don't know what to post as a code. I don't want to pollute the question with unnecessary code. Let's pretend that I have div with jquery event 'scroll', which fires angular function when div.scrollTop == 0. – Kindzoku Jul 11 '16 at 06:56
  • 1
    Seems that this question has the answer, you needed: [How to retain scroll position of ng-repeat in AngularJS?](http://stackoverflow.com/questions/23736647/how-to-retain-scroll-position-of-ng-repeat-in-angularjs) – omalyutin Jul 11 '16 at 06:56
  • Found solution here: http://stackoverflow.com/questions/23736647/how-to-retain-scroll-position-of-ng-repeat-in-angularjs – Kindzoku Jul 11 '16 at 06:58

0 Answers0