implement keyboard-related changes discussed in https://community.tt-rss.org/t/changing-the-amount-of-scroll-by-arrow-key/3452/7
This commit is contained in:
parent
3dc506a19a
commit
9ae9302b6b
|
@ -1029,8 +1029,8 @@
|
||||||
"prev_feed" => __("Open previous feed"),
|
"prev_feed" => __("Open previous feed"),
|
||||||
"next_article_or_scroll" => __("Open next article (in combined mode, scroll down)"),
|
"next_article_or_scroll" => __("Open next article (in combined mode, scroll down)"),
|
||||||
"prev_article_or_scroll" => __("Open previous article (in combined mode, scroll up)"),
|
"prev_article_or_scroll" => __("Open previous article (in combined mode, scroll up)"),
|
||||||
"next_article_page" => __("Scroll article by one page down"),
|
"next_headlines_page" => __("Scroll headlines by one page down"),
|
||||||
"prev_article_page" => __("Scroll article by one page up"),
|
"prev_headlines_page" => __("Scroll headlines by one page up"),
|
||||||
"next_article_noscroll" => __("Open next article"),
|
"next_article_noscroll" => __("Open next article"),
|
||||||
"prev_article_noscroll" => __("Open previous article"),
|
"prev_article_noscroll" => __("Open previous article"),
|
||||||
"next_article_noexpand" => __("Move to next article (don't expand)"),
|
"next_article_noexpand" => __("Move to next article (don't expand)"),
|
||||||
|
@ -1104,8 +1104,8 @@
|
||||||
"j" => "prev_feed",
|
"j" => "prev_feed",
|
||||||
"n" => "next_article_noscroll",
|
"n" => "next_article_noscroll",
|
||||||
"p" => "prev_article_noscroll",
|
"p" => "prev_article_noscroll",
|
||||||
//"(33)|PageUp" => "prev_article_page",
|
"N" => "article_page_down",
|
||||||
//"(34)|PageDown" => "next_article_page",
|
"P" => "article_page_up",
|
||||||
"*(33)|Shift+PgUp" => "article_page_up",
|
"*(33)|Shift+PgUp" => "article_page_up",
|
||||||
"*(34)|Shift+PgDn" => "article_page_down",
|
"*(34)|Shift+PgDn" => "article_page_down",
|
||||||
"(38)|Up" => "prev_article_or_scroll",
|
"(38)|Up" => "prev_article_or_scroll",
|
||||||
|
@ -1123,8 +1123,6 @@
|
||||||
"o" => "open_in_new_window",
|
"o" => "open_in_new_window",
|
||||||
"c p" => "catchup_below",
|
"c p" => "catchup_below",
|
||||||
"c n" => "catchup_above",
|
"c n" => "catchup_above",
|
||||||
"N" => "article_scroll_down",
|
|
||||||
"P" => "article_scroll_up",
|
|
||||||
"a W" => "toggle_widescreen",
|
"a W" => "toggle_widescreen",
|
||||||
"a e" => "toggle_full_text",
|
"a e" => "toggle_full_text",
|
||||||
"e" => "email_article",
|
"e" => "email_article",
|
||||||
|
|
|
@ -7,6 +7,33 @@ define(["dojo/_base/declare"], function (declare) {
|
||||||
hotkey_prefix: 0,
|
hotkey_prefix: 0,
|
||||||
hotkey_prefix_pressed: false,
|
hotkey_prefix_pressed: false,
|
||||||
hotkey_prefix_timeout: 0,
|
hotkey_prefix_timeout: 0,
|
||||||
|
Scrollable: {
|
||||||
|
scrollByPages: function (elem, page_offset, event) {
|
||||||
|
if (!elem) return;
|
||||||
|
|
||||||
|
/* keep a line or so from the previous page */
|
||||||
|
const offset = (elem.offsetHeight - (page_offset > 0 ? 50 : -50)) * page_offset;
|
||||||
|
|
||||||
|
this.scroll(elem, offset, event);
|
||||||
|
},
|
||||||
|
scroll: function(elem, offset, event) {
|
||||||
|
if (!elem) return;
|
||||||
|
|
||||||
|
if (event && 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;
|
||||||
|
},
|
||||||
|
},
|
||||||
constructor: function() {
|
constructor: function() {
|
||||||
window.onerror = this.Error.onWindowError;
|
window.onerror = this.Error.onWindowError;
|
||||||
},
|
},
|
||||||
|
|
|
@ -349,29 +349,10 @@ define(["dojo/_base/declare"], function (declare) {
|
||||||
return 0;
|
return 0;
|
||||||
},
|
},
|
||||||
scrollByPages: function (page_offset, event) {
|
scrollByPages: function (page_offset, event) {
|
||||||
const elem = App.isCombinedMode() ? $("headlines-frame") : $("content-insert");
|
App.Scrollable.scrollByPages($("content-insert"), page_offset, event);
|
||||||
|
|
||||||
const offset = elem.offsetHeight * page_offset * 0.99;
|
|
||||||
|
|
||||||
this.scroll(offset, event);
|
|
||||||
},
|
},
|
||||||
scroll: function (offset, event) {
|
scroll: function (offset, event) {
|
||||||
|
App.Scrollable.scroll($("content-insert"), offset, event);
|
||||||
const elem = App.isCombinedMode() ? $("headlines-frame") : $("content-insert");
|
|
||||||
|
|
||||||
if (event && 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;
|
||||||
|
|
|
@ -8,6 +8,7 @@ define(["dojo/_base/declare"], function (declare) {
|
||||||
headlines: [],
|
headlines: [],
|
||||||
current_first_id: 0,
|
current_first_id: 0,
|
||||||
_scroll_reset_timeout: false,
|
_scroll_reset_timeout: false,
|
||||||
|
line_scroll_offset: 120, /* px */
|
||||||
sticky_header_observer: new IntersectionObserver(
|
sticky_header_observer: new IntersectionObserver(
|
||||||
(entries, observer) => {
|
(entries, observer) => {
|
||||||
entries.forEach((entry) => {
|
entries.forEach((entry) => {
|
||||||
|
@ -363,23 +364,26 @@ define(["dojo/_base/declare"], function (declare) {
|
||||||
|
|
||||||
if (hl.active) {
|
if (hl.active) {
|
||||||
new_row.addClassName("active");
|
new_row.addClassName("active");
|
||||||
|
Article.unpack(new_row);
|
||||||
|
|
||||||
if (App.isCombinedMode())
|
if (App.isCombinedMode())
|
||||||
Article.cdmMoveToId(id, {noscroll: true});
|
Article.cdmMoveToId(id, {noscroll: true});
|
||||||
else
|
else
|
||||||
Article.view(id);
|
Article.view(id);
|
||||||
|
|
||||||
Article.unpack(row);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hl.selected) this.select("all", id);
|
if (hl.selected) this.select("all", id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$$(".cdm .header-sticky-guard").each((e) => { this.sticky_header_observer.observe(e) });
|
$$(".cdm .header-sticky-guard").each((e) => {
|
||||||
|
this.sticky_header_observer.observe(e)
|
||||||
|
});
|
||||||
|
|
||||||
if (App.getInitParam("cdm_expanded"))
|
if (App.getInitParam("cdm_expanded"))
|
||||||
$$("#headlines-frame > div[id*=RROW].cdm").each((e) => { this.unpack_observer.observe(e) });
|
$$("#headlines-frame > div[id*=RROW].cdm").each((e) => {
|
||||||
|
this.unpack_observer.observe(e)
|
||||||
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
render: function (headlines, hl) {
|
render: function (headlines, hl) {
|
||||||
|
@ -689,10 +693,14 @@ define(["dojo/_base/declare"], function (declare) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$$(".cdm .header-sticky-guard").each((e) => { this.sticky_header_observer.observe(e) });
|
$$(".cdm .header-sticky-guard").each((e) => {
|
||||||
|
this.sticky_header_observer.observe(e)
|
||||||
|
});
|
||||||
|
|
||||||
if (App.getInitParam("cdm_expanded"))
|
if (App.getInitParam("cdm_expanded"))
|
||||||
$$("#headlines-frame > div[id*=RROW].cdm").each((e) => { this.unpack_observer.observe(e) });
|
$$("#headlines-frame > div[id*=RROW].cdm").each((e) => {
|
||||||
|
this.unpack_observer.observe(e)
|
||||||
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
console.error("Invalid object received: " + transport.responseText);
|
console.error("Invalid object received: " + transport.responseText);
|
||||||
|
@ -799,21 +807,20 @@ define(["dojo/_base/declare"], function (declare) {
|
||||||
const noexpand = params.noexpand || false;
|
const noexpand = params.noexpand || false;
|
||||||
const event = params.event;
|
const event = params.event;
|
||||||
|
|
||||||
const rows = Headlines.getLoaded();
|
|
||||||
|
|
||||||
let prev_id = false;
|
let prev_id = false;
|
||||||
let next_id = false;
|
let next_id = false;
|
||||||
|
|
||||||
const active_row = $("RROW-" + Article.getActive());
|
const active_row = $("RROW-" + Article.getActive());
|
||||||
|
|
||||||
if (!active_row) {
|
if (!active_row)
|
||||||
Article.setActive(0);
|
Article.setActive(0);
|
||||||
}
|
|
||||||
|
|
||||||
if (!Article.getActive() || (active_row && !Headlines.isChildVisible(active_row, $("headlines-frame")))) {
|
if (!Article.getActive() || (active_row && !Headlines.isChildVisible(active_row, $("headlines-frame")))) {
|
||||||
next_id = Headlines.firstVisible();
|
next_id = Headlines.firstVisible();
|
||||||
prev_id = next_id;
|
prev_id = next_id;
|
||||||
} else {
|
} else {
|
||||||
|
const rows = Headlines.getLoaded();
|
||||||
|
|
||||||
for (let i = 0; i < rows.length; i++) {
|
for (let i = 0; i < rows.length; i++) {
|
||||||
if (rows[i] == Article.getActive()) {
|
if (rows[i] == Article.getActive()) {
|
||||||
|
|
||||||
|
@ -831,47 +838,31 @@ define(["dojo/_base/declare"], function (declare) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("cur: " + Article.getActive() + " next: " + next_id);
|
console.log("cur: " + Article.getActive() + " next: " + next_id + " prev:" + prev_id);
|
||||||
|
|
||||||
if (mode === "next") {
|
if (mode === "next") {
|
||||||
if (next_id || Article.getActive()) {
|
if (next_id) {
|
||||||
if (App.isCombinedMode()) {
|
if (App.isCombinedMode()) {
|
||||||
|
|
||||||
//const row = $("RROW-" + Article.getActive());
|
|
||||||
const ctr = $("headlines-frame");
|
|
||||||
|
|
||||||
if (noscroll) {
|
|
||||||
Article.setActive(next_id);
|
Article.setActive(next_id);
|
||||||
Article.cdmMoveToId(next_id, {event: event, noscroll: noscroll});
|
Article.cdmMoveToId(next_id, {event: event, noscroll: noscroll});
|
||||||
} else if (next_id) {
|
} else {
|
||||||
Article.scroll(ctr.offsetHeight / 2, event);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (next_id) {
|
|
||||||
Headlines.correctHeadlinesOffset(next_id);
|
Headlines.correctHeadlinesOffset(next_id);
|
||||||
Article.view(next_id, noexpand);
|
Article.view(next_id, noexpand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (mode === "prev") {
|
||||||
|
|
||||||
if (mode === "prev") {
|
|
||||||
if (prev_id || Article.getActive()) {
|
if (prev_id || Article.getActive()) {
|
||||||
if (App.isCombinedMode()) {
|
if (App.isCombinedMode()) {
|
||||||
|
|
||||||
const row = $("RROW-" + Article.getActive());
|
const row = $("RROW-" + Article.getActive());
|
||||||
//const prev_row = $("RROW-" + prev_id);
|
|
||||||
const ctr = $("headlines-frame");
|
const ctr = $("headlines-frame");
|
||||||
|
|
||||||
if (noscroll) {
|
|
||||||
if (row && Math.round(row.offsetTop) < Math.round(ctr.scrollTop)) {
|
if (row && Math.round(row.offsetTop) < Math.round(ctr.scrollTop)) {
|
||||||
Article.cdmMoveToId(Article.getActive(), {force: noscroll, event: event});
|
Article.cdmMoveToId(Article.getActive(), {force: noscroll, event: event});
|
||||||
} else if (prev_id) {
|
} else if (prev_id) {
|
||||||
Article.setActive(prev_id);
|
Article.setActive(prev_id);
|
||||||
Article.cdmMoveToId(prev_id, {force: noscroll, event: event, noscroll: noscroll});
|
Article.cdmMoveToId(prev_id, {force: noscroll, event: event, noscroll: noscroll});
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
Article.scroll(-ctr.offsetHeight / 2, event);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (prev_id) {
|
} else if (prev_id) {
|
||||||
Headlines.correctHeadlinesOffset(prev_id);
|
Headlines.correctHeadlinesOffset(prev_id);
|
||||||
|
@ -1360,21 +1351,11 @@ define(["dojo/_base/declare"], function (declare) {
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
scrollByPages: function (offset, event) {
|
scrollByPages: function (page_offset, event) {
|
||||||
const elem = $("headlines-frame");
|
App.Scrollable.scrollByPages($("headlines-frame"), page_offset, event);
|
||||||
|
},
|
||||||
if (event && event.repeat) {
|
scroll: function (offset, event) {
|
||||||
elem.addClassName("forbid-smooth-scroll");
|
App.Scrollable.scroll($("headlines-frame"), offset, event);
|
||||||
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")) {
|
||||||
|
|
32
js/tt-rss.js
32
js/tt-rss.js
|
@ -285,9 +285,15 @@ require(["dojo/_base/kernel",
|
||||||
if (rv) Feeds.open({feed: rv[0], is_cat: rv[1], delayed: true})
|
if (rv) Feeds.open({feed: rv[0], is_cat: rv[1], delayed: true})
|
||||||
};
|
};
|
||||||
this.hotkey_actions["next_article_or_scroll"] = function (event) {
|
this.hotkey_actions["next_article_or_scroll"] = function (event) {
|
||||||
|
if (App.isCombinedMode())
|
||||||
|
Headlines.scroll(Headlines.line_scroll_offset, event);
|
||||||
|
else
|
||||||
Headlines.move('next', {event: event});
|
Headlines.move('next', {event: event});
|
||||||
};
|
};
|
||||||
this.hotkey_actions["prev_article_or_scroll"] = function (event) {
|
this.hotkey_actions["prev_article_or_scroll"] = function (event) {
|
||||||
|
if (App.isCombinedMode())
|
||||||
|
Headlines.scroll(-Headlines.line_scroll_offset, event);
|
||||||
|
else
|
||||||
Headlines.move('prev', {event: event});
|
Headlines.move('prev', {event: event});
|
||||||
};
|
};
|
||||||
this.hotkey_actions["next_article_noscroll"] = function (event) {
|
this.hotkey_actions["next_article_noscroll"] = function (event) {
|
||||||
|
@ -335,27 +341,33 @@ require(["dojo/_base/kernel",
|
||||||
Headlines.catchupRelativeTo(0);
|
Headlines.catchupRelativeTo(0);
|
||||||
};
|
};
|
||||||
this.hotkey_actions["article_scroll_down"] = function (event) {
|
this.hotkey_actions["article_scroll_down"] = function (event) {
|
||||||
const ctr = App.isCombinedMode() ? $("headlines-frame") : $("content-insert");
|
if (App.isCombinedMode())
|
||||||
|
Headlines.scroll(Headlines.line_scroll_offset, event);
|
||||||
if (ctr)
|
else
|
||||||
Article.scroll(ctr.offsetHeight / 2, event);
|
Article.scroll(Headlines.line_scroll_offset, event);
|
||||||
};
|
};
|
||||||
this.hotkey_actions["article_scroll_up"] = function (event) {
|
this.hotkey_actions["article_scroll_up"] = function (event) {
|
||||||
const ctr = App.isCombinedMode() ? $("headlines-frame") : $("content-insert");
|
if (App.isCombinedMode())
|
||||||
|
Headlines.scroll(-Headlines.line_scroll_offset, event);
|
||||||
if (ctr)
|
else
|
||||||
Article.scroll(-ctr.offsetHeight / 2, event);
|
Article.scroll(-Headlines.line_scroll_offset, event);
|
||||||
};
|
};
|
||||||
this.hotkey_actions["next_article_page"] = function (event) {
|
this.hotkey_actions["next_headlines_page"] = function (event) {
|
||||||
Headlines.scrollByPages(1, event);
|
Headlines.scrollByPages(1, event);
|
||||||
};
|
};
|
||||||
this.hotkey_actions["prev_article_page"] = function (event) {
|
this.hotkey_actions["prev_headlines_page"] = function (event) {
|
||||||
Headlines.scrollByPages(-1, event);
|
Headlines.scrollByPages(-1, event);
|
||||||
};
|
};
|
||||||
this.hotkey_actions["article_page_down"] = function (event) {
|
this.hotkey_actions["article_page_down"] = function (event) {
|
||||||
|
if (App.isCombinedMode())
|
||||||
|
Headlines.scrollByPages(1, event);
|
||||||
|
else
|
||||||
Article.scrollByPages(1, event);
|
Article.scrollByPages(1, event);
|
||||||
};
|
};
|
||||||
this.hotkey_actions["article_page_up"] = function (event) {
|
this.hotkey_actions["article_page_up"] = function (event) {
|
||||||
|
if (App.isCombinedMode())
|
||||||
|
Headlines.scrollByPages(-1, event);
|
||||||
|
else
|
||||||
Article.scrollByPages(-1, event);
|
Article.scrollByPages(-1, event);
|
||||||
};
|
};
|
||||||
this.hotkey_actions["close_article"] = function () {
|
this.hotkey_actions["close_article"] = function () {
|
||||||
|
|
|
@ -4,7 +4,7 @@ class Hotkeys_Noscroll extends Plugin {
|
||||||
|
|
||||||
function about() {
|
function about() {
|
||||||
return array(1.0,
|
return array(1.0,
|
||||||
"n/p hotkeys move between articles without scrolling",
|
"n/p (and up/down) hotkeys move between articles without scrolling",
|
||||||
"fox");
|
"fox");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue