adaptable-text
Advanced tools
Comparing version 0.1.0 to 0.1.1
{ | ||
"name": "adaptable-text", | ||
"title": "Adaptable Text", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Adapt font size to fit text in element (WIP)", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
@@ -45,6 +45,10 @@ // Generated by CoffeeScript 1.9.2 | ||
var textWidth; | ||
this.text = this.element.value; | ||
this.text = this.element.value || this.element.textContent; | ||
textWidth = this._getTextWidth(this.text, this.styles.fontStyle + " " + this.currentFontSize + "px " + this.styles.fontFamily); | ||
this.previousFontSize = this.currentFontSize; | ||
this._checkSize(); | ||
this.element.style.fontSize = this.currentFontSize + "px"; | ||
if (this.previousFontSize !== this.currentFontSize) { | ||
this.currentFontSize = ~~(this.currentFontSize * 100) / 100; | ||
this.element.style.fontSize = this.currentFontSize + "px"; | ||
} | ||
}; | ||
@@ -103,5 +107,5 @@ | ||
AdaptableText.prototype._calculateMaxCharWidth = function(text, font) { | ||
AdaptableText.prototype._calculateMaxCharWidth = function() { | ||
var char, charWidth, chars, len; | ||
chars = 'qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM'.split(''); | ||
chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefhijklmnopqrstuvwxyz0123456789!?*()@£$%^&_-+=[]{}:;\'"\\|<>,./~`'.split(''); | ||
len = chars.length; | ||
@@ -108,0 +112,0 @@ while (len--) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
20505
306