Skip to content

Instantly share code, notes, and snippets.

@cvcodes
Last active July 8, 2018 05:09
Show Gist options
  • Save cvcodes/fadf035abf6d65c3748ff469a62bdecf to your computer and use it in GitHub Desktop.
Save cvcodes/fadf035abf6d65c3748ff469a62bdecf to your computer and use it in GitHub Desktop.
For Sololearn QnA solution used
class Component {
constructor(height, width, url, left, top, id) {
this.width = width;
this.height = height;
this.url = url;
this.left = left;
this.top = top;
this.id = id;
}
render() {
this.el = document.querySelector("img#" + this.id);
if(!this.el) {
alert('error: no ' + this.id + ' image element.');
return false;
}
this.el.src = this.url;
this.el.style.position = 'absolute';
this.el.style.left = this.left + 'px';
this.el.style.top = this.top + 'px';
this.el.style.width = this.width + 'px';
this.el.style.height = this.height + 'px';
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment