diff --git a/app/javascript/src/javascripts/comments.js b/app/javascript/src/javascripts/comments.js index 9347e24b7..88cacd24f 100644 --- a/app/javascript/src/javascripts/comments.js +++ b/app/javascript/src/javascripts/comments.js @@ -39,7 +39,7 @@ Comment.show_new_comment_form = function(e) { $(e.target).hide(); var $form = $(e.target).closest("div.new-comment").find("form"); $form.show(); - Utility.scroll_to($form); + $form[0].scrollIntoView(false); e.preventDefault(); } diff --git a/app/javascript/src/javascripts/notes.js b/app/javascript/src/javascripts/notes.js index 43f4a6586..7e42aba87 100644 --- a/app/javascript/src/javascripts/notes.js +++ b/app/javascript/src/javascripts/notes.js @@ -145,7 +145,7 @@ let Note = { Note.Body.show(note_id); $(".note-box-highlighted").removeClass("note-box-highlighted"); $note_box.addClass("note-box-highlighted"); - Utility.scroll_to($note_box); + $note_box[0].scrollIntoView(false); }, resize_inner_border: function($note_box) { diff --git a/app/javascript/src/javascripts/utility.js b/app/javascript/src/javascripts/utility.js index 1fb3c7879..8d83ce3bb 100644 --- a/app/javascript/src/javascripts/utility.js +++ b/app/javascript/src/javascripts/utility.js @@ -12,24 +12,6 @@ Utility.test_max_width = function(width) { return mq.matches; } -Utility.scrolling = false; - -Utility.scroll_to = function(element) { - if (Utility.scrolling) { - return; - } else { - Utility.scrolling = true; - } - - var top = null; - if (typeof element === "number") { - top = element; - } else { - top = element.offset().top - 10; - } - $('html, body').animate({scrollTop: top}, 300, "linear", function() {Utility.scrolling = false;}); -} - Utility.notice_timeout_id = undefined; Utility.notice = function(msg, permanent) { diff --git a/app/views/forum_posts/new.js.erb b/app/views/forum_posts/new.js.erb index fe0a171da..92bcc3378 100644 --- a/app/views/forum_posts/new.js.erb +++ b/app/views/forum_posts/new.js.erb @@ -4,7 +4,5 @@ if ($("#forum_post_body").val().length > 0) { } $("#forum_post_body").val(msg); $("#topic-response").show(); -$('html, body').animate({ - scrollTop: $("#forum_post_body").offset().top - 100 -}, 500); +document.body.scrollIntoView(false); $("#forum_post_body").selectEnd(); diff --git a/app/views/forum_topics/show.html.erb b/app/views/forum_topics/show.html.erb index 97598ef62..ce5a027d2 100644 --- a/app/views/forum_topics/show.html.erb +++ b/app/views/forum_topics/show.html.erb @@ -49,11 +49,7 @@ $(function() { $("#new-response-link").click(function(e) { $("#topic-response").show(); - - $('html, body').animate({ - scrollTop: $("#forum_post_body").offset().top - 100 - }, 500); - + document.body.scrollIntoView(false); e.preventDefault(); }) });