Commit 099603ed authored by JC Brand's avatar JC Brand

chatview: Reduce debounce time for markScrolled from 100ms to 50ms

parent fc42f290
...@@ -272,7 +272,7 @@ converse.plugins.add('converse-chatview', { ...@@ -272,7 +272,7 @@ converse.plugins.add('converse-chatview', {
}, },
initDebounced () { initDebounced () {
this.scrollDown = debounce(this._scrollDown, 100); this.scrollDown = debounce(this._scrollDown, 50);
this.markScrolled = debounce(this._markScrolled, 100); this.markScrolled = debounce(this._markScrolled, 100);
}, },
...@@ -433,7 +433,7 @@ converse.plugins.add('converse-chatview', { ...@@ -433,7 +433,7 @@ converse.plugins.add('converse-chatview', {
await Promise.all(this.model.messages.map(m => this.onMessageAdded(m))); await Promise.all(this.model.messages.map(m => this.onMessageAdded(m)));
this.insertIntoDOM(); this.insertIntoDOM();
this.scrollDown(); this.scrollDown();
this.content.addEventListener('scroll', this.markScrolled.bind(this)); this.content.addEventListener('scroll', () => this.markScrolled());
/** /**
* Triggered whenever a `_converse.ChatBox` instance has fetched its messages from * Triggered whenever a `_converse.ChatBox` instance has fetched its messages from
* `sessionStorage` but **NOT** from the server. * `sessionStorage` but **NOT** from the server.
...@@ -1261,14 +1261,17 @@ converse.plugins.add('converse-chatview', { ...@@ -1261,14 +1261,17 @@ converse.plugins.add('converse-chatview', {
} }
}, },
_markScrolled: function (ev) { /**
/* Called when the chat content is scrolled up or down. * Called when the chat content is scrolled up or down.
* We want to record when the user has scrolled away from * We want to record when the user has scrolled away from
* the bottom, so that we don't automatically scroll away * the bottom, so that we don't automatically scroll away
* from what the user is reading when new messages are * from what the user is reading when new messages are received.
* received. *
*/ * Don't call this method directly, instead, call `markScrolled`,
if (ev && ev.preventDefault) { ev.preventDefault(); } * which debounces this method by 100ms.
* @private
*/
_markScrolled: function () {
let scrolled = true; let scrolled = true;
const is_at_bottom = const is_at_bottom =
(this.content.scrollTop + this.content.clientHeight) >= (this.content.scrollTop + this.content.clientHeight) >=
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment