Article.cdmScrollToId: disable smooth scrolling on repeated events

master
Andrew Dolgov 5 years ago
parent dad3d1c7a9
commit 560346f9d1

@ -275,7 +275,7 @@ define(["dojo/_base/declare"], function (declare) {
dialog.show(); dialog.show();
}, },
cdmScrollToId: function (id, force) { cdmScrollToId: function (id, force, event) {
const ctr = $("headlines-frame"); const ctr = $("headlines-frame");
const e = $("RROW-" + id); const e = $("RROW-" + id);
@ -284,6 +284,18 @@ define(["dojo/_base/declare"], function (declare) {
if (force || e.offsetTop + e.offsetHeight > (ctr.scrollTop + ctr.offsetHeight) || if (force || e.offsetTop + e.offsetHeight > (ctr.scrollTop + ctr.offsetHeight) ||
e.offsetTop < ctr.scrollTop) { e.offsetTop < ctr.scrollTop) {
if (event && event.repeat) {
ctr.addClassName("forbid-smooth-scroll");
window.clearTimeout(this._scroll_reset_timeout);
this._scroll_reset_timeout = window.setTimeout(() => {
if (ctr) ctr.removeClassName("forbid-smooth-scroll");
}, 250)
} else {
ctr.removeClassName("forbid-smooth-scroll");
}
ctr.scrollTop = e.offsetTop; ctr.scrollTop = e.offsetTop;
Element.hide("floatingTitle"); Element.hide("floatingTitle");

@ -868,7 +868,7 @@ define(["dojo/_base/declare"], function (declare) {
Article.scroll(ctr.offsetHeight / 2, event); Article.scroll(ctr.offsetHeight / 2, event);
} else if (next_id) { } else if (next_id) {
Article.setActive(next_id); Article.setActive(next_id);
Article.cdmScrollToId(next_id, true); Article.cdmScrollToId(next_id, true, event);
} }
} else if (next_id) { } else if (next_id) {
@ -890,10 +890,10 @@ define(["dojo/_base/declare"], function (declare) {
Article.scroll(-ctr.offsetHeight / 2, event); Article.scroll(-ctr.offsetHeight / 2, event);
} else { } else {
if (row.offsetTop < ctr.scrollTop) { if (row.offsetTop < ctr.scrollTop) {
Article.cdmScrollToId(Article.getActive(), noscroll); Article.cdmScrollToId(Article.getActive(), noscroll, event);
} else if (prev_id) { } else if (prev_id) {
Article.setActive(prev_id); Article.setActive(prev_id);
Article.cdmScrollToId(prev_id, noscroll); Article.cdmScrollToId(prev_id, noscroll, event);
} }
} }

Loading…
Cancel
Save