/
githubmirror
/
ionic
Обзор
Документация
Войти
/
githubmirror
/
ionic
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/angular/common/src/providers/dom-controller.ts
45 строк
1009 B
Liam DeBeasi
feat(angular): ship Ionic components as Angular standalone components (#28311)
10 окт 2023, 20:06
Не верифицирован
10 окт 2023, 20:06
57e2476
Код
Авторство
О чём код?
import { Injectable } from '@angular/core'; @Injectable({ providedIn: 'root', }) export class DomController { /** * Schedules a task to run during the READ phase of the next frame. * This task should only read the DOM, but never modify it. */ read(cb: RafCallback): void { getQueue().read(cb); } /** * Schedules a task to run during the WRITE phase of the next frame. * This task should write the DOM, but never READ it. */ write(cb: RafCallback): void { getQueue().write(cb); } } const getQueue = () => { const win = typeof (window as any) !== 'undefined' ? window : (null as any); if (win != null) { const Ionic = win.Ionic; if (Ionic?.queue) { return Ionic.queue; } return { read: (cb: any) => win.requestAnimationFrame(cb), write: (cb: any) => win.requestAnimationFrame(cb), }; } return { read: (cb: any) => cb(), write: (cb: any) => cb(), }; }; export type RafCallback = (timeStamp?: number) => void;