diff --git a/4chan_x.user.js b/4chan_x.user.js index 0fd10c0be..7a63ba227 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1454,10 +1454,13 @@ }; _Class.prototype.select = function() { - var data, _i, _len, _ref, _ref2; + var data, rectEl, rectList, _i, _len, _ref, _ref2; if ((_ref = qr.selected) != null) _ref.el.id = null; qr.selected = this; this.el.id = 'selected'; + rectEl = this.el.getBoundingClientRect(); + rectList = this.el.parentNode.getBoundingClientRect(); + this.el.parentNode.scrollLeft += rectEl.left + rectEl.width / 2 - rectList.left - rectList.width / 2; _ref2 = ['name', 'email', 'sub', 'com']; for (_i = 0, _len = _ref2.length; _i < _len; _i++) { data = _ref2[_i]; diff --git a/script.coffee b/script.coffee index 30b909707..28cbc264f 100644 --- a/script.coffee +++ b/script.coffee @@ -1070,6 +1070,10 @@ qr = qr.selected?.el.id = null qr.selected = @ @el.id = 'selected' + # Scroll the list to center the focused reply. + rectEl = @el.getBoundingClientRect() + rectList = @el.parentNode.getBoundingClientRect() + @el.parentNode.scrollLeft += rectEl.left + rectEl.width/2 - rectList.left - rectList.width/2 for data in ['name', 'email', 'sub', 'com'] $("[name=#{data}]", qr.el).value = @[data] $('#spoiler', qr.el).checked = @spoiler