User:Dorumin/scrollfix.​js

// Provides a scrolling fix for chat sometimes not scrolling to the bottom.  importArticle({   type: 'script',    article: 'u:dev:MediaWiki:Chat-js/code.js' });

mw.hook('dev.chat.render').add(function {   function get_room {        return mainRoom.chats.privates[mainRoom.activeRoom] || mainRoom;    }

function bind_messages(fn) { mainRoom.model.chats.bind('afteradd', fn); mainRoom.model.privateUsers.bind('add', function(u) {           mainRoom.chats.privates[u.attributes.roomId].model.chats.bind('afteradd', fn);        }); }

bind_messages(function {       var vd = get_room.viewDiscussion,        div = vd.chatDiv.get(0);        if (div.scrollHeight - div.scrollTop - div.clientHeight < 200) {            vd.scrollToBottom;        }    }); });