Skip to content

Instantly share code, notes, and snippets.

@brendt
Created September 2, 2015 11:07
Show Gist options
  • Save brendt/6f31978c3801080d26bb to your computer and use it in GitHub Desktop.
Save brendt/6f31978c3801080d26bb to your computer and use it in GitHub Desktop.
Vanilla JS: Wordcloud - Word.js #1
"use strict";
var Word = {
init() {
this.state = {
rendered : false,
};
this.domElem = null;
},
render(text) {
if (!this.rendered) {
var word = document.createElement('div');
word.setAttribute('class', 'word');
this.domElem = word;
this.state.rendered = true;
}
return this.domElem;
},
setText(text) {
this.domElem.textContent = text;
},
getWidth() {
return this.domElem.offsetWidth;
},
setBounds(marginLeft) {
this.domElem.style['margin-left'] = marginLeft + 'px';
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment