Rudchyk
3/19/2020 - 12:46 PM

getComputedStyle

/**
 * @param {any} ctx
 * @param {string} cssRule
 * @param {boolean} number Is convert to the number
 * @return {string}
 */
export default function(ctx, cssRule, number = false) {
  const elem = typeof ctx === "string" ? document.querySelector(ctx) : ctx;
  const style = window.getComputedStyle(elem, null).getPropertyValue(cssRule);
  if (number) {
    return parseInt(style, 10);
  } else {
    return style;
  }
}