Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: input field inside slide doesnt work on android #162

Open
Overpowered opened this issue Apr 13, 2018 · 3 comments
Open

BUG: input field inside slide doesnt work on android #162

Overpowered opened this issue Apr 13, 2018 · 3 comments

Comments

@Overpowered
Copy link

Hi, thx for your great script! I chose your one, because its very lightweight (not full of unnecessary stuff) and good to handle ... BUT ;) there is an annoying bug.

Input fields (inside a slide) will not work on android (I use android 8). If I click inside the input field, the keyboard will slide in and in the same step also slide out. So the keyboard will not stay (input isnt possible).

Here is my example fiddle:
https://jsfiddle.net/cjobq2o5/

Hope you can fix it?

@jisi724
Copy link

jisi724 commented Nov 8, 2018

Have the same issue here.

The reason is actually the resizeHandler method, which caused lots of problems I would say. This method would be triggered in many situations that window size doesn't change, like scrolling or clicking input fields.

Here is a quick fix you can try @Overpowered : extends a new class from Siema, and overwrite the resizeHandler method then you will see the keyboard stay there as usual.

@craigpryde
Copy link

Incase anyone hits this issue. I have addressed this in my code by extending from siema and overriding the resizeHandler();

I have added the following to my code:

    class Carousel extends Siema {
        // Store width to perform check
        _currrentViewWidth = window.innerWidth;

        resizeHandler() {
            // This is used to prevent the resize handler firing when the 
            // Android keyboard pops up.
            if(Math.abs(window.innerWidth - this._currrentViewWidth) === 0) {
                return; 
            }
        
            this._currrentViewWidth = window.innerWidth;
            ... rest of the resize handler code.
        }
    }

What i am doing is storing the current window innerwidth with:

    _currrentViewWidth = window.innerWidth;

And then using that value as a reference in the original resize handler to check if the window width has changed. i.e > 0px difference. And if the viewport size does change then update the stored reference.

    if(Math.abs(window.innerWidth - this._currrentViewWidth) === 0) {
        return; 
    }
        
    this._currrentViewWidth = window.innerWidth;

Hopefully this helps.

@andsat
Copy link

andsat commented Mar 28, 2022

Thanks for the fix! This is also a bug on Firefox mobile. Strangely, iOS Safari works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants