summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2019-12-10 12:55:24 +0300
committerAndrew Dolgov <[email protected]>2019-12-10 12:55:24 +0300
commit3993198aa78a11e8f224c43ec0ac4588e7d8c402 (patch)
tree8738f7d929b5dea28e78d10949cc348123fd9f5a /js
parent7d0bbe996236f2ae8ca2bf8e2fd09547345262f5 (diff)
when moving next or previous and currently active article is entirely invisible, start moving from first visible one
Diffstat (limited to 'js')
-rwxr-xr-xjs/Headlines.js24
1 files changed, 19 insertions, 5 deletions
diff --git a/js/Headlines.js b/js/Headlines.js
index 47129c109..25244f195 100755
--- a/js/Headlines.js
+++ b/js/Headlines.js
@@ -256,6 +256,18 @@ define(["dojo/_base/declare"], function (declare) {
etop < ctop && ebottom > ctop || ebottom > cbottom && etop < cbottom
},
+ firstVisible: function() {
+ const rows = $$("#headlines-frame > div[id*=RROW]");
+ const ctr = $("headlines-frame");
+
+ for (let i = 0; i < rows.length; i++) {
+ const row = rows[i];
+
+ if (this.isChildVisible(row, ctr)) {
+ return row.getAttribute("data-article-id");
+ }
+ }
+ },
scrollHandler: function (/*event*/) {
try {
Headlines.unpackVisible();
@@ -830,13 +842,15 @@ define(["dojo/_base/declare"], function (declare) {
let prev_id = false;
let next_id = false;
- if (!$('RROW-' + Article.getActive())) {
+ const active_row = $("RROW-" + Article.getActive());
+
+ if (!active_row) {
Article.setActive(0);
}
- if (!Article.getActive()) {
- next_id = rows[0];
- prev_id = rows[rows.length - 1]
+ if (!Article.getActive() || (active_row && !Headlines.isChildVisible(active_row, $("headlines-frame")))) {
+ next_id = Headlines.firstVisible();
+ prev_id = next_id;
} else {
for (let i = 0; i < rows.length; i++) {
if (rows[i] == Article.getActive()) {
@@ -889,7 +903,7 @@ define(["dojo/_base/declare"], function (declare) {
if (!noscroll) {
Article.scroll(-ctr.offsetHeight / 2, event);
} else {
- if (row.offsetTop < ctr.scrollTop) {
+ if (row && row.offsetTop < ctr.scrollTop) {
Article.cdmScrollToId(Article.getActive(), noscroll, event);
} else if (prev_id) {
Article.setActive(prev_id);