summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2019-12-10 08:51:45 +0300
committerAndrew Dolgov <[email protected]>2019-12-10 08:51:45 +0300
commit560346f9d19f521db1adfbad2cab8c0c61e16cf7 (patch)
treec17965fa57458148e9c24aa7936a86d9213b6273 /js
parentdad3d1c7a9555f484d5c4070d1ad86632372f3ec (diff)
Article.cdmScrollToId: disable smooth scrolling on repeated events
Diffstat (limited to 'js')
-rw-r--r--js/Article.js14
-rwxr-xr-xjs/Headlines.js6
2 files changed, 16 insertions, 4 deletions
diff --git a/js/Article.js b/js/Article.js
index 1b92c2965..78ace5d0b 100644
--- a/js/Article.js
+++ b/js/Article.js
@@ -275,7 +275,7 @@ define(["dojo/_base/declare"], function (declare) {
dialog.show();
},
- cdmScrollToId: function (id, force) {
+ cdmScrollToId: function (id, force, event) {
const ctr = $("headlines-frame");
const e = $("RROW-" + id);
@@ -284,6 +284,18 @@ define(["dojo/_base/declare"], function (declare) {
if (force || e.offsetTop + e.offsetHeight > (ctr.scrollTop + ctr.offsetHeight) ||
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;
Element.hide("floatingTitle");
diff --git a/js/Headlines.js b/js/Headlines.js
index 796c182e5..99f911838 100755
--- a/js/Headlines.js
+++ b/js/Headlines.js
@@ -868,7 +868,7 @@ define(["dojo/_base/declare"], function (declare) {
Article.scroll(ctr.offsetHeight / 2, event);
} else if (next_id) {
Article.setActive(next_id);
- Article.cdmScrollToId(next_id, true);
+ Article.cdmScrollToId(next_id, true, event);
}
} else if (next_id) {
@@ -890,10 +890,10 @@ define(["dojo/_base/declare"], function (declare) {
Article.scroll(-ctr.offsetHeight / 2, event);
} else {
if (row.offsetTop < ctr.scrollTop) {
- Article.cdmScrollToId(Article.getActive(), noscroll);
+ Article.cdmScrollToId(Article.getActive(), noscroll, event);
} else if (prev_id) {
Article.setActive(prev_id);
- Article.cdmScrollToId(prev_id, noscroll);
+ Article.cdmScrollToId(prev_id, noscroll, event);
}
}