Debounce resize event to avoid performance bottleneck

This commit is contained in:
Jérémie Astori 2018-04-06 00:40:27 -04:00
parent 7355db94d6
commit 527cac4c75
No known key found for this signature in database
GPG Key ID: B9A4F245CD67BDE8

View File

@ -1,11 +1,13 @@
"use strict";
const $ = require("jquery");
const debounce = require("lodash/debounce");
const Mousetrap = require("mousetrap");
const options = require("./options");
const socket = require("./socket");
const templates = require("../views");
const chat = $("#chat");
const Mousetrap = require("mousetrap");
module.exports = renderPreview;
@ -83,7 +85,7 @@ function appendPreview(preview, msg, template) {
}
};
$(window).on("resize", showMoreIfNeeded);
$(window).on("resize", debounce(showMoreIfNeeded, 150));
window.requestAnimationFrame(showMoreIfNeeded);
if (activeChannelId === channelId) {