import FontFaceObserver from 'fontfaceobserver' export const getType = (v: any) => Object.prototype.toString.call(v) export const isFunction = (v: any) => getType(v) === '[object Function]' export const isObject = (v: any) => getType(v) === '[object Object]' export const getIsPadDisplay = () => window.innerWidth >= 1024 && window.innerWidth > window.innerHeight export const noop = () => {} export function loadPrimaryFont(el = document.body) { const FONT_LOAD_MAX_TIME = 30000 const FONT_NAME = 'FZY4JW' const font = new FontFaceObserver(FONT_NAME) font.load(null, FONT_LOAD_MAX_TIME).then(() => { el.style.fontFamily = FONT_NAME }, noop) } export const toArray = (target: any) => Array.prototype.slice.call(target) export const preloadImage = (imgList: Array) => Promise.all(imgList.map(loadImage)) export const loadImage = (imgSrc: string) => new Promise((resolve, reject) => { const img = new Image() img.src = imgSrc img.onload = () => { resolve() } img.onerror = () => { reject() } })