mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
Improve
This commit is contained in:
@@ -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()
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user