From 5a249b0b84b50b258e3d1d3f0023f549f8a9b59c Mon Sep 17 00:00:00 2001 From: Jeremy Zhang Date: Thu, 9 Aug 2018 05:14:50 +0000 Subject: [PATCH] Scroll to bottom when images start to load in --- webapp/titanembeds/static/js/embed.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/webapp/titanembeds/static/js/embed.js b/webapp/titanembeds/static/js/embed.js index e3fd220..2129d4a 100644 --- a/webapp/titanembeds/static/js/embed.js +++ b/webapp/titanembeds/static/js/embed.js @@ -1238,6 +1238,13 @@ } return reacts; } + + function scroll_on_dom_update() { + var scrollRegion = $(window).height() / 2; + if (!getParameterByName("scrollbartheme") && $("main").prop("scrollHeight") - ($("main").scrollTop() + $("main").outerHeight()) < scrollRegion) { + $("main").scrollTop($("#chatcontent").outerHeight()); + } + } function fill_discord_messages(messages, jumpscroll, replace) { if (replace === undefined) { @@ -1341,6 +1348,7 @@ } } } + $("#chatcontent img").on("load", scroll_on_dom_update); $('#chatcontent').linkify({ target: "_blank" });