Fix height of textarea to multiple of 24px

This commit is contained in:
Peter Stuifzand 2020-10-31 13:35:59 +01:00
parent 47d504903d
commit c92adb32d3

View File

@ -21,7 +21,9 @@ function textareaAutosizeIinit($) {
parseInt(this.$element.css('borderBottomWidth')) || 0; parseInt(this.$element.css('borderBottomWidth')) || 0;
if (containsText(this.element.value)) { if (containsText(this.element.value)) {
this.$element.height(this.element.scrollHeight - diff); let height = this.element.scrollHeight - diff;
height = 24 * Math.round(height / 24)
this.$element.height(height);
} }
// keyup is required for IE to properly reset height when deleting text // keyup is required for IE to properly reset height when deleting text
@ -29,9 +31,11 @@ function textareaAutosizeIinit($) {
var $window = $(window); var $window = $(window);
var currentScrollPosition = $window.scrollTop(); var currentScrollPosition = $window.scrollTop();
let height = this.scrollHeight - diff;
height = 24 * Math.round(height / 24)
$(this) $(this)
.height(0) .height(0)
.height(this.scrollHeight - diff); .height(height);
$window.scrollTop(currentScrollPosition); $window.scrollTop(currentScrollPosition);
}); });