summaryrefslogtreecommitdiff
path: root/app/views/game
diff options
context:
space:
mode:
authorDavid Gay <david@davidgay.org>2021-06-09 21:49:46 -0400
committerDavid Gay <david@davidgay.org>2021-06-09 21:49:51 -0400
commit779f19c5b35f7c8c7690dac9fbf4606f49cfffde (patch)
tree115131c535b3b2577e2f92eb1e914d79a17feb6b /app/views/game
parent40db33e9789f85b55bdf3dc02fe6c6a7547a2378 (diff)
Only scroll chat and results output to the bottom on new content when already scrolled to the bottom or near the bottom
Diffstat (limited to 'app/views/game')
-rw-r--r--app/views/game/finish_activity.js.erb10
1 files changed, 7 insertions, 3 deletions
diff --git a/app/views/game/finish_activity.js.erb b/app/views/game/finish_activity.js.erb
index f37c142..fa3d228 100644
--- a/app/views/game/finish_activity.js.erb
+++ b/app/views/game/finish_activity.js.erb
@@ -5,9 +5,13 @@ var outputHTML = "<%= j render(partial: "application/results", locals: { results
if (resultOutputDiv) {
resultOutputDiv.innerHTML += outputHTML;
- resultOutputDiv.scrollTo({
- top: resultOutputDiv.scrollHeight, left: 0, behavior: 'smooth'
- });
+
+ // If scrolled to the bottom or near the bottom, then smooth scroll to the bottom.
+ if ((resultOutputDiv.scrollTop + 100) >= (resultOutputDiv.scrollHeight - resultOutputDiv.offsetHeight)) {
+ resultOutputDiv.scrollTo({
+ top: resultOutputDiv.scrollHeight, left: 0, behavior: 'smooth'
+ });
+ }
}
if (resultControlsDiv) {