From 560346f9d19f521db1adfbad2cab8c0c61e16cf7 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 10 Dec 2019 08:51:45 +0300 Subject: Article.cdmScrollToId: disable smooth scrolling on repeated events --- js/Article.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'js/Article.js') 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"); -- cgit v1.2.3