March 2018
Intermediate to advanced
592 pages
13h 44m
English
We want to figure out if the scrollTop plus the clientHeight is greater than or equal to the scrollHeight. If it is, then we want to go ahead and scroll the user to the bottom because we know they're already near the bottom, if (clientHeight + scrollTop is >= scrollHeight):
var scrollHeight = message.prop('scrollHeight');if (clientHeight + scrollTop >= scrollHeight) {}
Now if this is the case then, we are going to go ahead and do something. For now, we'll just use console.log to print a little message to the screen. We'll just print Should scroll:
if (clientHeight + scrollTop >= scrollHeight) { console.log('Should scroll');}
Now our calculation is not quite complete, since we are running this function. After we ...