Created
September 2, 2015 11:07
-
-
Save brendt/6f31978c3801080d26bb to your computer and use it in GitHub Desktop.
Vanilla JS: Wordcloud - Word.js #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"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