mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 12:09:20 +03:00
Replace timeOutAction() with debounce
Replace delegateRun() Revert my throttle/debounce setTimeout() to Function.prototype[throttle/debounce]
This commit is contained in:
parent
f6a55898c7
commit
97a73c6639
28 changed files with 225 additions and 372 deletions
|
|
@ -31,25 +31,18 @@ class AbstractApp extends AbstractBoot {
|
|||
this.isLocalAutocomplete = true;
|
||||
this.lastErrorTime = 0;
|
||||
|
||||
var t;
|
||||
addEventListener(
|
||||
'resize',
|
||||
()=>{
|
||||
// throttle
|
||||
if (!t) {
|
||||
t = setTimeout(()=>{
|
||||
const iH = $win.height(),
|
||||
iW = $win.height();
|
||||
(()=>{
|
||||
const iH = $win.height(),
|
||||
iW = $win.height();
|
||||
|
||||
if ($win.__sizes[0] !== iH || $win.__sizes[1] !== iW) {
|
||||
$win.__sizes[0] = iH;
|
||||
$win.__sizes[1] = iW;
|
||||
dispatchEvent(new CustomEvent('resize.real'));
|
||||
}
|
||||
t = 0;
|
||||
}, 50);
|
||||
if ($win.__sizes[0] !== iH || $win.__sizes[1] !== iW) {
|
||||
$win.__sizes[0] = iH;
|
||||
$win.__sizes[1] = iW;
|
||||
dispatchEvent(new CustomEvent('resize.real'));
|
||||
}
|
||||
}
|
||||
}).throttle(50)
|
||||
);
|
||||
|
||||
const $doc = document;
|
||||
|
|
@ -64,12 +57,7 @@ class AbstractApp extends AbstractBoot {
|
|||
}
|
||||
});
|
||||
|
||||
var d;
|
||||
const fn = ()=>{
|
||||
// debounce
|
||||
clearTimeout(d);
|
||||
d = setTimeout(()=>dispatchEvent(new CustomEvent('rl.auto-logout-refresh')), 5000);
|
||||
}
|
||||
const fn = (()=>dispatchEvent(new CustomEvent('rl.auto-logout-refresh'))).debounce(5000);
|
||||
|
||||
$doc.addEventListener('mousemove', fn);
|
||||
$doc.addEventListener('keypress', fn);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue