From d4311291581f57cce1789155cc8ce8ae6fd80162 Mon Sep 17 00:00:00 2001 From: David Gay Date: Thu, 10 Jun 2021 09:27:38 -0400 Subject: Start results div scrolled to bottom on page changes --- app/javascript/controllers/results_controller.js | 13 +++++++++++++ app/views/layouts/application.html.erb | 2 ++ 2 files changed, 15 insertions(+) create mode 100644 app/javascript/controllers/results_controller.js (limited to 'app') diff --git a/app/javascript/controllers/results_controller.js b/app/javascript/controllers/results_controller.js new file mode 100644 index 0000000..266b80c --- /dev/null +++ b/app/javascript/controllers/results_controller.js @@ -0,0 +1,13 @@ +import { Controller } from "stimulus"; + +export default class extends Controller { + static targets = [ "output" ]; + + connect() { + this.scrollToBottom(); + } + + scrollToBottom() { + this.outputTarget.scrollTop = this.outputTarget.scrollHeight; + } +} diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 309dc29..048a6ed 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -40,6 +40,8 @@
-- cgit v1.2.3