Skip to content

Instantly share code, notes, and snippets.

@XianYeeXing
Created March 29, 2019 11:05
Show Gist options
  • Save XianYeeXing/5ce0c19e7b08587a2b09dd8fcaa23462 to your computer and use it in GitHub Desktop.
Save XianYeeXing/5ce0c19e7b08587a2b09dd8fcaa23462 to your computer and use it in GitHub Desktop.
Example of updating dom style
let _el = null;
const _getEl = sel => {
if(_el === null) {
_el = document.querySelector(sel);
}
return _el;
}
module.exports = opts => {
const el = _getEl();
el.setAttribute('src', opts.src);
el.style.left = opts.left;
el.style.top = opts.top;
el.style.width = opts.width;
el.style.height = opts.height;
///el.style.display = 'block';
return el;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment