exp: auto-disable smooth scrolling for repeat hotkey events

This commit is contained in:
Andrew Dolgov 2019-12-09 22:42:43 +03:00
parent 008afb97a9
commit e7dd634183
10 changed files with 80 additions and 42 deletions

View File

@ -659,6 +659,10 @@ body.ttrss_main #headlines-frame div.feed-title a:hover {
body.ttrss_main #headlines-frame.smooth-scroll {
scroll-behavior: smooth;
}
body.ttrss_main #headlines-frame.forbid-smooth-scroll,
body.ttrss_main #content-insert.forbid-smooth-scroll {
scroll-behavior: auto;
}
body.ttrss_main #toolbar-frame_splitter {
display: none;
}

File diff suppressed because one or more lines are too long

View File

@ -776,6 +776,11 @@ body.ttrss_main {
scroll-behavior: smooth;
}
#headlines-frame.forbid-smooth-scroll,
#content-insert.forbid-smooth-scroll {
scroll-behavior : auto;
}
#toolbar-frame_splitter {
display : none;
}

View File

@ -2,6 +2,7 @@
/* global __, ngettext */
define(["dojo/_base/declare"], function (declare) {
Article = {
_scroll_reset_timeout: false,
getScoreClass: function (score) {
if (score > 500) {
return "score-high";
@ -314,33 +315,42 @@ define(["dojo/_base/declare"], function (declare) {
else
return 0;
},
scrollByPages: function (offset) {
if (!App.isCombinedMode()) {
const ci = $("content-insert");
if (ci) {
ci.scrollTop += ci.offsetHeight * offset * 0.99;
}
} else {
const hi = $("headlines-frame");
if (hi) {
hi.scrollTop += hi.offsetHeight * offset * 0.99;
}
scrollByPages: function (page_offset, event) {
let elem;
if (!App.isCombinedMode()) {
elem = $("content-insert");
} else {
elem = $("headlines-frame");
}
const offset = elem.offsetHeight * page_offset * 0.99;
this.scroll(offset, event);
},
scroll: function (offset) {
if (!App.isCombinedMode()) {
const ci = $("content-insert");
if (ci) {
ci.scrollTop += offset;
}
} else {
const hi = $("headlines-frame");
if (hi) {
hi.scrollTop += offset;
}
scroll: function (offset, event) {
let elem;
if (!App.isCombinedMode()) {
elem = $("content-insert");
} else {
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 += offset;
},
mouseIn: function (id) {
this.post_under_pointer = id;

View File

@ -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")) {

View File

@ -213,7 +213,7 @@ require(["dojo/_base/kernel",
const action_func = this.hotkey_actions[action_name];
if (action_func != null) {
action_func();
action_func(event);
event.stopPropagation();
return false;
}
@ -324,23 +324,23 @@ require(["dojo/_base/kernel",
this.hotkey_actions["catchup_above"] = function () {
Headlines.catchupRelativeTo(0);
};
this.hotkey_actions["article_scroll_down"] = function () {
Article.scroll(40);
this.hotkey_actions["article_scroll_down"] = function (event) {
Article.scroll(80, event);
};
this.hotkey_actions["article_scroll_up"] = function () {
Article.scroll(-40);
this.hotkey_actions["article_scroll_up"] = function (event) {
Article.scroll(-80, event);
};
this.hotkey_actions["next_article_page"] = function () {
Headlines.scrollByPages(1);
this.hotkey_actions["next_article_page"] = function (event) {
Headlines.scrollByPages(1, event);
};
this.hotkey_actions["prev_article_page"] = function () {
Headlines.scrollByPages(-1);
this.hotkey_actions["prev_article_page"] = function (event) {
Headlines.scrollByPages(-1, event);
};
this.hotkey_actions["article_page_down"] = function () {
Article.scrollByPages(1);
this.hotkey_actions["article_page_down"] = function (event) {
Article.scrollByPages(1, event);
};
this.hotkey_actions["article_page_up"] = function () {
Article.scrollByPages(-1);
this.hotkey_actions["article_page_up"] = function (event) {
Article.scrollByPages(-1, event);
};
this.hotkey_actions["close_article"] = function () {
if (App.isCombinedMode()) {

View File

@ -660,6 +660,10 @@ body.ttrss_main #headlines-frame div.feed-title a:hover {
body.ttrss_main #headlines-frame.smooth-scroll {
scroll-behavior: smooth;
}
body.ttrss_main #headlines-frame.forbid-smooth-scroll,
body.ttrss_main #content-insert.forbid-smooth-scroll {
scroll-behavior: auto;
}
body.ttrss_main #toolbar-frame_splitter {
display: none;
}

File diff suppressed because one or more lines are too long

View File

@ -660,6 +660,10 @@ body.ttrss_main #headlines-frame div.feed-title a:hover {
body.ttrss_main #headlines-frame.smooth-scroll {
scroll-behavior: smooth;
}
body.ttrss_main #headlines-frame.forbid-smooth-scroll,
body.ttrss_main #content-insert.forbid-smooth-scroll {
scroll-behavior: auto;
}
body.ttrss_main #toolbar-frame_splitter {
display: none;
}

File diff suppressed because one or more lines are too long