1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-08-08 23:03:50 +00:00
This commit is contained in:
Jeremy Ruston 2013-03-06 22:12:21 +00:00
parent 5075238917
commit f85afdb964

View File

@ -118,15 +118,15 @@ TextEditor.prototype.fixHeight = function() {
var self = this; var self = this;
if(this.editWidget.children[0].domNode && this.editWidget.children[0].domNode.type === "textarea") { if(this.editWidget.children[0].domNode && this.editWidget.children[0].domNode.type === "textarea") {
$tw.utils.nextTick(function() { $tw.utils.nextTick(function() {
var wrapper = self.editWidget.renderer.domNode, // Resize the textarea to fit its content
textarea = self.editWidget.children[0].domNode; var textarea = self.editWidget.children[0].domNode,
// Set the text area height to 1px temporarily, which allows us to read the true scrollHeight scrollTop = document.body.scrollTop;
var prevWrapperHeight = wrapper.style.height; textarea.style.height = "auto";
wrapper.style.height = textarea.style.height + "px"; var newHeight = Math.max(textarea.scrollHeight + textarea.offsetHeight - textarea.clientHeight,MIN_TEXT_AREA_HEIGHT);
textarea.style.overflow = "hidden"; if(newHeight !== textarea.offsetHeight) {
textarea.style.height = "1px"; textarea.style.height = newHeight + "px";
textarea.style.height = Math.max(textarea.scrollHeight,MIN_TEXT_AREA_HEIGHT) + "px"; document.body.scrollTop = scrollTop;
wrapper.style.height = prevWrapperHeight; }
}); });
} }
}; };