/
githubmirror
/
angular.js
Обзор
Документация
Войти
/
githubmirror
/
angular.js
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/ngAnimate/rafScheduler.js
50 строк
1 KB
Justas Brazauskas
docs: fix typos throughout the codebase
11 дек 2015, 22:04
11 дек 2015, 22:04
e57cf13
Код
Авторство
О чём код?
'use strict'; var $$rAFSchedulerFactory = ['$$rAF', function($$rAF) { var queue, cancelFn; function scheduler(tasks) { // we make a copy since RAFScheduler mutates the state // of the passed in array variable and this would be difficult // to track down on the outside code queue = queue.concat(tasks); nextTick(); } queue = scheduler.queue = []; /* waitUntilQuiet does two things: * 1. It will run the FINAL `fn` value only when an uncanceled RAF has passed through * 2. It will delay the next wave of tasks from running until the quiet `fn` has run. * * The motivation here is that animation code can request more time from the scheduler * before the next wave runs. This allows for certain DOM properties such as classes to * be resolved in time for the next animation to run. */ scheduler.waitUntilQuiet = function(fn) { if (cancelFn) cancelFn(); cancelFn = $$rAF(function() { cancelFn = null; fn(); nextTick(); }); }; return scheduler; function nextTick() { if (!queue.length) return; var items = queue.shift(); for (var i = 0; i < items.length; i++) { items[i](); } if (!cancelFn) { $$rAF(function() { if (!cancelFn) nextTick(); }); } } }];