You know how it most of the chats, the scroll goes down, when a new message appears. My chat reloads every 5000 ms, and then drags the scroll down 300ms after.
But I want to make it, so when user drags the scroll up, the scroll drag won't affect him. Is there a function, to fill a variable like, draggedScroll = true once the user scrolled up?
http://driptone.com/jony/applications/chat/index.php
this is the chat, and as you see, if you go up, it will drag you every 5000ms down, and I want to prevent it ONLY when the user scrolls up. and if the user has scrolled to the bottom [0] again, it will make draggedScroll = false, so it will affect him again.
How do I do that?
Problem hasn't been solved!
Problem explanation:
The scroll will only work IF the height of the scroll will be at-least 1500px (scrollTop(1500)) (34 messages in chat).
If it is below that, scroll will not work, and will scroll up upon new message.
I had the problem myself and this is how I solved it:
scroll
event of the appropriate container$(element).scrollTop()
$(element).prop('scrollHeight')
$(element).height()
scrollTop == scrollHeight - height
true
: enable automated scrolling, disable it otherwise.My solution (written in CoffeeScript)
Basically what I did there, I took the current position of the scroll, and added 470 px to it (since it will always be lower than the whole height).
And then check, if the new height, is < than the old height + 150px.
If yes, then scroll down. else stay on same position.
Have a check on the
element.scrollTop
. If it is equal to theelement.scrollHeight - element.height
do the scrolling, else do not scroll.Just set a flag while scrollbar isdraged, like:
UPDATE: right, checking bScroll