styles.js

  1. /**
  2. * Style related functions
  3. *
  4. * @namespace Styles
  5. */
  6. /**
  7. * Get the computed style for an element's style property
  8. * @memberof Styles
  9. * @param { Element } el
  10. * @param { String } proptName CSS property name
  11. * @return { String }
  12. */
  13. function getStyle(el, proptName) {
  14. return getComputedStyle(el)[proptName];
  15. }
  16. /**
  17. * Set an element's style
  18. * @memberof Styles
  19. * @param { HTMLElement } el
  20. * @param { String } proptName CSS property name
  21. * @param { String } proptVal CSS property value
  22. */
  23. function setStyle(el, proptName, proptVal) {
  24. el.style[proptName] = proptVal;
  25. }
  26. export {
  27. getStyle,
  28. setStyle
  29. };