Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/roundcube/roundcubemail.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2020-09-24 18:20:23 +0300
committerAleksander Machniak <alec@alec.pl>2020-09-24 18:21:20 +0300
commit7d9571354d853c3777d27bd1ce0f724ee12f8ec7 (patch)
tree065a13da3e214cfdc9b2618c78778218c5ddbb3b /skins/elastic
parentd2bd6b72c1db20b2c20ecf71b2ec6ae0563b0985 (diff)
Fix scroll jump on key press in plain text mode of the HTML editor (#7622)
Diffstat (limited to 'skins/elastic')
-rw-r--r--skins/elastic/ui.js24
1 files changed, 13 insertions, 11 deletions
diff --git a/skins/elastic/ui.js b/skins/elastic/ui.js
index 247aee666..0c6b45d6e 100644
--- a/skins/elastic/ui.js
+++ b/skins/elastic/ui.js
@@ -3742,34 +3742,36 @@ function rcube_elastic_ui()
*/
function textarea_autoresize_init(textarea)
{
- var padding = parseInt($(textarea).css('padding-top')) + parseInt($(textarea).css('padding-bottom')) + 2,
- // FIXME: Is there a better way to get initial height of the textarea?
- // At this moment clientHeight/offsetHeight is 0.
- min_height = ($(textarea)[0].rows || 5) * 21,
+ var padding, minHeight,
resize = function() {
// Wait until the textarea is visible
if (!textarea.scrollHeight) {
return setTimeout(resize, 250);
}
- if (textarea.scrollHeight - padding <= min_height) {
+ if (!padding) {
+ padding = parseInt($(textarea).css('padding-top')) + parseInt($(textarea).css('padding-bottom')) + 2;
+ minHeight = $(textarea).height();
+ }
+
+ if (textarea.scrollHeight - padding <= minHeight) {
return;
}
- // To fix scroll-jump issue in Edge we'll find the scrolling parent
- // and re-apply scrollTop value after we reset textarea height
+ // To fix scroll-jump we'll re-apply scrollTop to the (scrolled) parent
+ // after we reset textarea height
var scroll_element, scroll_pos = 0;
$(textarea).parents().each(function() {
- if (textarea.scrollTop > 0) {
- scroll_element = textarea;
- scroll_pos = textarea.scrollTop;
+ if (this.scrollTop > 0) {
+ scroll_element = this;
+ scroll_pos = this.scrollTop;
return false;
}
});
var oldHeight = $(textarea).outerHeight();
$(textarea).outerHeight(0);
- var newHeight = Math.max(min_height, textarea.scrollHeight);
+ var newHeight = Math.max(minHeight, textarea.scrollHeight);
$(textarea).outerHeight(oldHeight);
if (newHeight !== oldHeight) {
$(textarea).height(newHeight);