summaryrefslogtreecommitdiff
path: root/js/AppBase.js
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2020-05-22 21:48:03 +0300
committerAndrew Dolgov <[email protected]>2020-05-22 21:48:03 +0300
commit409ba0db2dea5b52365f3d26043a02d7576b1c8d (patch)
tree29268633bb26ec06fc98f28c5f6b7044a8d5c4f8 /js/AppBase.js
parentc8cc845d5b1c64ea259667c01a9591a04e0e4e98 (diff)
- RIP smooth scrolling and associated hacks
- attempt to make Headlines.move() / Article.cdmMoveToId() behave a bit more intuitively
Diffstat (limited to 'js/AppBase.js')
-rw-r--r--js/AppBase.js24
1 files changed, 9 insertions, 15 deletions
diff --git a/js/AppBase.js b/js/AppBase.js
index c4882267d..4aa500e5b 100644
--- a/js/AppBase.js
+++ b/js/AppBase.js
@@ -8,29 +8,17 @@ define(["dojo/_base/declare"], function (declare) {
hotkey_prefix_pressed: false,
hotkey_prefix_timeout: 0,
Scrollable: {
- scrollByPages: function (elem, page_offset, event) {
+ scrollByPages: function (elem, page_offset) {
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);
+ this.scroll(elem, offset);
},
- scroll: function(elem, offset, event) {
+ scroll: function(elem, offset) {
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;
},
isChildVisible: function(elem, ctr) {
@@ -45,6 +33,12 @@ define(["dojo/_base/declare"], function (declare) {
return etop >= ctop && ebottom <= cbottom ||
etop < ctop && ebottom > ctop || ebottom > cbottom && etop < cbottom;
},
+ fitsInContainer: function (elem, ctr) {
+ if (!elem) return;
+
+ return elem.offsetTop + elem.offsetHeight <= ctr.scrollTop + ctr.offsetHeight &&
+ elem.offsetTop >= ctr.scrollTop;
+ }
},
constructor: function() {
window.onerror = this.Error.onWindowError;