UNPKG

vuikit

Version:

A responsive Vue UI library for web site interfaces based on UIkit

53 lines (49 loc) 1.14 kB
/** * Vuikit 0.8.10 * (c) 2018 Miljan Aleksic * @license MIT **/ /* Substantial part of the code is adapted from UIkit, Copyright (c) 2013-2018 YOOtheme GmbH, getuikit.com */ var fastdom = { reads: [], writes: [], read: function read (task) { this.reads.push(task); scheduleFlush(); return task }, write: function write (task) { this.writes.push(task); scheduleFlush(); return task }, clear: function clear (task) { return remove(this.reads, task) || remove(this.writes, task) }, flush: function flush () { runTasks(this.reads); runTasks(this.writes.splice(0, this.writes.length)); this.scheduled = false; if (this.reads.length || this.writes.length) { scheduleFlush(); } } }; function scheduleFlush () { if (!fastdom.scheduled) { fastdom.scheduled = true; requestAnimationFrame(fastdom.flush.bind(fastdom)); } } function runTasks (tasks) { var task; while ((task = tasks.shift())) { task(); } } function remove (array, item) { var index = array.indexOf(item); return !!~index && !!array.splice(index, 1) } export { fastdom };