Determining the calculation

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 ...

Get Advanced Node.js Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.