1
0
mirror of https://git.tt-rss.org/git/tt-rss.git synced 2025-12-13 16:45:55 +00:00

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 { body.ttrss_main #headlines-frame.smooth-scroll {
scroll-behavior: smooth; 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 { body.ttrss_main #toolbar-frame_splitter {
display: none; 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; scroll-behavior: smooth;
} }
#headlines-frame.forbid-smooth-scroll,
#content-insert.forbid-smooth-scroll {
scroll-behavior : auto;
}
#toolbar-frame_splitter { #toolbar-frame_splitter {
display : none; display : none;
} }

View File

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

View File

@@ -7,6 +7,7 @@ define(["dojo/_base/declare"], function (declare) {
_observer_counters_timeout: 0, _observer_counters_timeout: 0,
headlines: [], headlines: [],
current_first_id: 0, current_first_id: 0,
_scroll_reset_timeout: false,
row_observer: new MutationObserver((mutations) => { row_observer: new MutationObserver((mutations) => {
const modified = []; const modified = [];
@@ -1383,11 +1384,21 @@ define(["dojo/_base/declare"], function (declare) {
} }
}, },
scrollByPages: function (offset) { scrollByPages: function (offset, event) {
const hi = $("headlines-frame"); const elem = $("headlines-frame");
if (hi) {
hi.scrollTop += hi.offsetHeight * offset * 0.99; 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 () { initHeadlinesMenu: function () {
if (!dijit.byId("headlinesMenu")) { if (!dijit.byId("headlinesMenu")) {

View File

@@ -213,7 +213,7 @@ require(["dojo/_base/kernel",
const action_func = this.hotkey_actions[action_name]; const action_func = this.hotkey_actions[action_name];
if (action_func != null) { if (action_func != null) {
action_func(); action_func(event);
event.stopPropagation(); event.stopPropagation();
return false; return false;
} }
@@ -324,23 +324,23 @@ require(["dojo/_base/kernel",
this.hotkey_actions["catchup_above"] = function () { this.hotkey_actions["catchup_above"] = function () {
Headlines.catchupRelativeTo(0); Headlines.catchupRelativeTo(0);
}; };
this.hotkey_actions["article_scroll_down"] = function () { this.hotkey_actions["article_scroll_down"] = function (event) {
Article.scroll(40); Article.scroll(80, event);
}; };
this.hotkey_actions["article_scroll_up"] = function () { this.hotkey_actions["article_scroll_up"] = function (event) {
Article.scroll(-40); Article.scroll(-80, event);
}; };
this.hotkey_actions["next_article_page"] = function () { this.hotkey_actions["next_article_page"] = function (event) {
Headlines.scrollByPages(1); Headlines.scrollByPages(1, event);
}; };
this.hotkey_actions["prev_article_page"] = function () { this.hotkey_actions["prev_article_page"] = function (event) {
Headlines.scrollByPages(-1); Headlines.scrollByPages(-1, event);
}; };
this.hotkey_actions["article_page_down"] = function () { this.hotkey_actions["article_page_down"] = function (event) {
Article.scrollByPages(1); Article.scrollByPages(1, event);
}; };
this.hotkey_actions["article_page_up"] = function () { this.hotkey_actions["article_page_up"] = function (event) {
Article.scrollByPages(-1); Article.scrollByPages(-1, event);
}; };
this.hotkey_actions["close_article"] = function () { this.hotkey_actions["close_article"] = function () {
if (App.isCombinedMode()) { 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 { body.ttrss_main #headlines-frame.smooth-scroll {
scroll-behavior: smooth; 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 { body.ttrss_main #toolbar-frame_splitter {
display: none; 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 { body.ttrss_main #headlines-frame.smooth-scroll {
scroll-behavior: smooth; 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 { body.ttrss_main #toolbar-frame_splitter {
display: none; display: none;
} }

File diff suppressed because one or more lines are too long