Skip to content

Commit

Permalink
自适应高度
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Jul 5, 2015
1 parent b082670 commit 5b54813
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build/MDEditor.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@
};
MDEditor.prototype.setMD = function(val) {
if (marked) this.textarea.value = val ? val : this.opts.value;
if (this.textarea.scrollHeight > this.opts.maxheight) this.textarea.style.height = this.opts.maxheight + "px";
if (this.textarea.scrollHeight < this.opts.maxheight) this.textarea.style.height = this.textarea.scrollHeight + "px"; else if (this.textarea.scrollHeight > this.opts.maxheight) this.textarea.style.height = this.opts.maxheight + "px";
return this;
};
MDEditor.prototype.getHTML = function() {
Expand Down
4 changes: 3 additions & 1 deletion lib/MDEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@
*/
MDEditor.prototype.setMD =function(val){
if(marked) this.textarea.value = val?val:this.opts.value;
if(this.textarea.scrollHeight>this.opts.maxheight)
if(this.textarea.scrollHeight<this.opts.maxheight)
this.textarea.style.height = this.textarea.scrollHeight + 'px';
else if(this.textarea.scrollHeight>this.opts.maxheight)
this.textarea.style.height = this.opts.maxheight + 'px';
return this;
}
Expand Down

0 comments on commit 5b54813

Please sign in to comment.