diff options
author | Kohei Yoshino <kohei.yoshino@gmail.com> | 2018-01-03 16:32:05 +0100 |
---|---|---|
committer | Dylan William Hardison <dylan@hardison.net> | 2018-01-03 16:32:05 +0100 |
commit | cf5aa47fadffcc555543ffb3d606008c8f733cde (patch) | |
tree | 1cfabc763ce3a050ab3aab1eafa8ae8b59b7a7c6 /extensions/BugModal/web/common_bug_modal.js | |
parent | 1ece54f087f04778b21e94cc52084bec629fc012 (diff) | |
download | bugzilla-cf5aa47fadffcc555543ffb3d606008c8f733cde.tar.gz bugzilla-cf5aa47fadffcc555543ffb3d606008c8f733cde.tar.xz |
Bug 1426685 - Fix regressions from fixed-positioning global header
Diffstat (limited to 'extensions/BugModal/web/common_bug_modal.js')
-rw-r--r-- | extensions/BugModal/web/common_bug_modal.js | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/extensions/BugModal/web/common_bug_modal.js b/extensions/BugModal/web/common_bug_modal.js index cc7f31dfd..160f922cc 100644 --- a/extensions/BugModal/web/common_bug_modal.js +++ b/extensions/BugModal/web/common_bug_modal.js @@ -141,7 +141,7 @@ $(function() { $('#top-btn') .click(function(event) { event.preventDefault(); - $.scrollTo($('body')); + $.scrollTo($('#main-inner')); }); // bottom btn @@ -1348,31 +1348,26 @@ $(function() { return -1; }, - // Bring an element into view, leaving space for the outline. - // If passed a string, it will be treated as an id - the page will scroll - // unanimated and the url will be added to the browser's history. - // If passed an element, an smooth scroll will take place and no entry - // will be added to the history. + // Bring an element into view, leaving space for the outline. If passed + // a string, it will be treated as an id - the page will scroll and the + // url will be added to the browser's history. If passed an element, no + // entry will be added to the history. scrollTo: function(target, complete) { + let $target; + if (typeof target === 'string') { - var el = $('#' + target); + $target = $('#' + target); window.location.hash = target; - var $html = $('html'); - if (Math.abs($html.scrollTop() - el.offset().top) <= 1) { - $html.scrollTop($html.scrollTop() - 10); - } - $html.scrollLeft(0); + } else { + $target = target; } - else { - var offset = target.offset(); - $('html') - .animate({ - scrollTop: offset.top - 20, - scrollLeft: 0 - }, - 200, - complete - ); + + if ($target.length) { + $('main').scrollTop(Math.round($target.position().top) - 20); + } + + if (complete) { + complete(); } } |