This commit is contained in:
Peter Maquiran
2021-08-17 11:15:49 +01:00
parent 926d4f4a38
commit d323428de4
9 changed files with 163 additions and 143 deletions
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { WaitForDomService } from './wait-for-dom.service';
describe('WaitForDomService', () => {
let service: WaitForDomService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(WaitForDomService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
@@ -0,0 +1,24 @@
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class WaitForDomService {
selectorString = ""
constructor() { }
selector({ selector, callback }) {
function _try() {
if (!document.querySelector(selector)) {
window.requestAnimationFrame(_try);
} else {
callback()
}
};
_try()
}
}