mirror of https://github.com/OCA/web.git
commit
afb1a42451
|
@ -12,14 +12,6 @@ export function useRefreshAnimation(timeout) {
|
|||
const refreshClass = "o_content__refresh";
|
||||
let timeoutId = null;
|
||||
|
||||
/**
|
||||
* @returns {DOMTokenList|null}
|
||||
*/
|
||||
function contentClassList() {
|
||||
const content = document.querySelector(".o_content");
|
||||
return content ? content.classList : null;
|
||||
}
|
||||
|
||||
function clearAnimationTimeout() {
|
||||
if (timeoutId) {
|
||||
clearTimeout(timeoutId);
|
||||
|
@ -29,11 +21,20 @@ export function useRefreshAnimation(timeout) {
|
|||
|
||||
function animate() {
|
||||
clearAnimationTimeout();
|
||||
contentClassList().add(refreshClass);
|
||||
timeoutId = setTimeout(() => {
|
||||
contentClassList().remove(refreshClass);
|
||||
clearAnimationTimeout();
|
||||
}, timeout);
|
||||
const content = document.querySelector(".o_content");
|
||||
if (content) {
|
||||
content.classList.add(refreshClass);
|
||||
timeoutId = setTimeout(() => {
|
||||
// Check if element still exists in DOM after timeout
|
||||
if (
|
||||
document.contains(content) &&
|
||||
content.classList.contains(refreshClass)
|
||||
) {
|
||||
content.classList.remove(refreshClass);
|
||||
}
|
||||
clearAnimationTimeout();
|
||||
}, timeout);
|
||||
}
|
||||
}
|
||||
|
||||
return animate;
|
||||
|
|
Loading…
Reference in New Issue