summaryrefslogtreecommitdiff
path: root/js/Headlines.js
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2019-12-09 22:42:43 +0300
committerAndrew Dolgov <[email protected]>2019-12-09 22:42:43 +0300
commite7dd634183154949fab7aa0b00844eb645cb87e5 (patch)
tree22ef8eeb2cf9295c26a97f8961da11b6d038d0a3 /js/Headlines.js
parent008afb97a9c7dc1ef62e0e87fa73cf46aeb09f40 (diff)
exp: auto-disable smooth scrolling for repeat hotkey events
Diffstat (limited to 'js/Headlines.js')
-rwxr-xr-xjs/Headlines.js19
1 files changed, 15 insertions, 4 deletions
diff --git a/js/Headlines.js b/js/Headlines.js
index 52c1c5842..058376266 100755
--- a/js/Headlines.js
+++ b/js/Headlines.js
@@ -7,6 +7,7 @@ define(["dojo/_base/declare"], function (declare) {
_observer_counters_timeout: 0,
headlines: [],
current_first_id: 0,
+ _scroll_reset_timeout: false,
row_observer: new MutationObserver((mutations) => {
const modified = [];
@@ -1383,11 +1384,21 @@ define(["dojo/_base/declare"], function (declare) {
}
},
- scrollByPages: function (offset) {
- const hi = $("headlines-frame");
- if (hi) {
- hi.scrollTop += hi.offsetHeight * offset * 0.99;
+ scrollByPages: function (offset, event) {
+ const elem = $("headlines-frame");
+
+ if (event.repeat) {
+ elem.addClassName("forbid-smooth-scroll");
+ window.clearTimeout(this._scroll_reset_timeout);
+
+ this._scroll_reset_timeout = window.setTimeout(() => {
+ if (elem) elem.removeClassName("forbid-smooth-scroll");
+ }, 250)
+ } else {
+ elem.removeClassName("forbid-smooth-scroll");
}
+
+ elem.scrollTop += elem.offsetHeight * offset * 0.99;
},
initHeadlinesMenu: function () {
if (!dijit.byId("headlinesMenu")) {