framework7 icon indicating copy to clipboard operation
framework7 copied to clipboard

resizeTextarea makes page blinking and scroll position reset when input

Open Poordeveloper opened this issue 10 years ago • 11 comments

app.resizeTextarea = function (textarea) { textarea = $(textarea); if (!textarea.hasClass('resizable')) { return; } textarea.css({'height': ''}); var height = textarea[0].offsetHeight; var diff = height - textarea[0].clientHeight; var scrollHeight = textarea[0].scrollHeight;

if (scrollHeight + diff > height) {
    var newAreaHeight = scrollHeight + diff;
    textarea.css('height', newAreaHeight + 'px');
}

};

I just remove above bold line "textarea.css({'height': ''});", everything works fine though textarea size can not be decreased.

Poordeveloper avatar Feb 06 '16 18:02 Poordeveloper

Where do you see such issue and on which device? I can't replicate it

nolimits4web avatar Feb 07 '16 09:02 nolimits4web

http://codepen.io/Poordeveloper/pen/RrVOjq

Poordeveloper avatar Feb 09 '16 15:02 Poordeveloper

Exactly the same issue with my app with Cordova on iOS. But I don't understand why it's working in kitchen sink...

Llaume avatar Feb 28 '16 19:02 Llaume

this code textarea.css({'height': ''}); required to reduce textarea's size with edit or clear it.

I fixed a blinking effect by adding delay (100ms) to textarea size updating function

    app.resizableTextarea = function (textarea) {
        textarea = $(textarea);
        if (textarea.length === 0) return;
        var textareaTimeout;
        function handleTextarea() {
            clearTimeout(textareaTimeout);
            textareaTimeout = setTimeout(function () {
                app.resizeTextarea(textarea);
            }, 100); //niko
        }
        textarea[0].f7DestroyResizableTextarea = function () {
            textarea.off('change keydown keypress keyup paste cut', handleTextarea);
        };
        return textarea.on('change keydown keypress keyup paste cut', handleTextarea);
    };

softexe avatar May 11 '16 19:05 softexe

Could you please expand you point? Consider pointing code snippets here, on Codepen or on JSFiddle. Make sure you have read the documentation correctly and followed any instructions it may give.

ZanderBrown avatar Mar 01 '17 17:03 ZanderBrown

There hasn't been a response by the issues owner in 20 days. This issue will be closed in 7 days if no further response is submitted

ZanderBrown avatar Mar 01 '17 17:03 ZanderBrown

it was in device's webview only, not in desktop browsers...

softexe avatar Mar 01 '17 17:03 softexe

I have this blinking on iOS device (both iPhone 7 device and emulator) when resizeTextarea on bottom of the page and keyboad are open. Commenting textarea.css({'height': ''}) on app.resizeTextarea function fix this issue, but textarea size doesn't decreases on text deleting. P.S. On Android device there is no such blinking on text input.

applecat avatar Mar 22 '17 09:03 applecat

@nolimits4web any thoughts?

ZanderBrown avatar Mar 22 '17 16:03 ZanderBrown

I had similar issues in UIWebView when using translate3D or translateZ in CSS so that hardware acceleration through GPU was triggered.

Try to use WKWebView in Cordova.

valnub avatar May 31 '17 22:05 valnub

It was fixed in v2

nolimits4web avatar Jan 27 '18 19:01 nolimits4web