UNPKG

vuikit

Version:

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

62 lines (57 loc) 1.6 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 */ import { getCssVar } from '../util/style'; import { isObject, isString, toFloat } from '../util/lang'; function toMedia (value) { if (isString(value)) { if (value[0] === '@') { var name = "media-" + (value.substr(1)); value = toFloat(getCssVar(name)); } else if (isNaN(value)) { return value } } return value && !isNaN(value) ? ("(min-width: " + value + "px)") : false } function debounce (fn, wait, immediate) { var timeout; return function () { var context = this; var args = arguments; var later = function () { timeout = null; if (!immediate) { fn.apply(context, args); } }; var callNow = immediate && !timeout; clearTimeout(timeout); timeout = setTimeout(later, wait); if (callNow) { fn.apply(context, args); } } } function get (obj, path, defVal) { var result = isObject(obj) && isString(path) ? _get(obj, path) : undefined; return result === undefined ? defVal : result } function _get (obj, path) { return path.split('.').reduce(function (acc, val) { return acc && acc[val]; }, obj) } function range (start, stop, step) { if ( step === void 0 ) step = 1; if (typeof stop === 'undefined') { stop = start; start = 0; } return Array.from(new Array(Math.floor((stop - start) / step)), function (x, i) { return start + (i * step); }) } export { toMedia, debounce, get, range };