Skip to content

Commit

Permalink
Call requestAnimationFrame via DomWindowHelper
Browse files Browse the repository at this point in the history
  • Loading branch information
dk981234 committed Apr 3, 2024
1 parent 132e0aa commit 6277efb
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/utils/animation.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { DomWindowHelper } from "src/global_variables_utils";
import { debounce } from "./taskmanager";

export interface AnimationOptions{
Expand Down Expand Up @@ -76,8 +77,8 @@ export class AnimationUtils {
if(isCancel) {
element.classList.remove(options.cssClass);
} else {
requestAnimationFrame(() => {
requestAnimationFrame(() => {
DomWindowHelper.requestAnimationFrame(() => {
DomWindowHelper.requestAnimationFrame(() => {
element.classList.remove(options.cssClass);
});
});
Expand Down Expand Up @@ -110,11 +111,11 @@ export class AnimationPropertyUtils extends AnimationUtils {
this.beforeAnimationRun(element, options);
this.runEnterAnimation(element, options);
};
requestAnimationFrame(() => {
DomWindowHelper.requestAnimationFrame(() => {
if(getElement()) {
callback();
} else {
requestAnimationFrame(callback);
DomWindowHelper.requestAnimationFrame(callback);
}
});
}
Expand All @@ -127,7 +128,7 @@ export class AnimationPropertyUtils extends AnimationUtils {
export class AnimationGroupUtils<T> extends AnimationUtils {
public onEnter(getElement: (el: T) => HTMLElement, getOptions: (el: T) => AnimationOptions, elements: Array<T>): void {
if(elements.length == 0) return;
requestAnimationFrame(() => {
DomWindowHelper.requestAnimationFrame(() => {
const callback = () => {
elements.forEach((el) => {
this.beforeAnimationRun(getElement(el), getOptions(el));
Expand All @@ -137,7 +138,7 @@ export class AnimationGroupUtils<T> extends AnimationUtils {
});
};
if(!getElement(elements[0])) {
requestAnimationFrame(callback);
DomWindowHelper.requestAnimationFrame(callback);
} else {
callback();
}
Expand Down Expand Up @@ -214,4 +215,4 @@ export class AnimationGroup<T> extends AnimationProperty<Array<T>, [T]> {
this.update(newValue);
}
}
}
}

0 comments on commit 6277efb

Please sign in to comment.