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

Mobile on resize won't restore menus and flash of unstyled content #18

Open
dingo-d opened this issue Feb 26, 2016 · 6 comments
Open

Mobile on resize won't restore menus and flash of unstyled content #18

dingo-d opened this issue Feb 26, 2016 · 6 comments

Comments

@dingo-d
Copy link

dingo-d commented Feb 26, 2016

I have put the okayNav() inside a function, so that I can call it on resize like this

function navigation(){
    $('#nav-main').okayNav({
        swipe_enabled : false,
    });
}

navigation();

$(window).on('resize', function(){
    navigation();
});

The problem is that the resizing seems to only work when you go from fullscreen navigation (desktop) towards the mobile (smaller resolutions), but not the other way around.

The only way I made it work if I made my browser full screen. On mobile devices this is not the case. And this is an issue when I'm in portrait mode and go to landscape mode.

So far I've tested this on Android Galaxy S6, and on a windows tablet, but I recon the same will happen on ipads and iphones.

Also is there any way, on mobile devices, to prevent the flash of unstyled content? Because I can see all of my menu which collapses once the page loads. Or do I need to manually implement something like setTimeout()?

Thanks

@dingo-d
Copy link
Author

dingo-d commented Feb 26, 2016

Ok, so it seems that the resize issue is happening in Chrome only (a thing that one would never expect). The weird thing is that the codepen example works on Chrome fine.

I also have errors with revolution slider and common.js only on chrome.

@VPenkov
Copy link
Owner

VPenkov commented Feb 26, 2016

In your case you can use $('#nav-main').okayNav('recalcNav'); on resize.
Also, okayNav already tracks your window size and calls the recalcNav method on resize.

In order to be more helpful, I'd need an URL to see what's wrong. You can mail it to me on hi@vergilpenkov.com if privacy is an issue.

@dingo-d
Copy link
Author

dingo-d commented Feb 29, 2016

I'll try your solution and see if it works, and if it doesn't I'll mail you the url. Thanks!

@dingo-d
Copy link
Author

dingo-d commented Feb 29, 2016

Ok, so I've made a hack that seems to be fixing the Chrome issue:

    function navigation(){
        $('#nav-main').okayNav({
            swipe_enabled : false
        });
        $('#nav-main').okayNav('recalcNav');
    }

    navigation();

    $(window).on('resize', function(){
        $('#nav-main').okayNav('destroy');
        navigation();
    });

Which is a hack, but seems to be working. I'm destroying it and rebuilding on every resize. Not super happy about it, but it does the job.

@dingo-d dingo-d closed this as completed Feb 29, 2016
@VPenkov
Copy link
Owner

VPenkov commented Feb 29, 2016

Might be a bug. Will definitely look into it.

@VPenkov VPenkov reopened this Feb 29, 2016
@dingo-d
Copy link
Author

dingo-d commented Feb 29, 2016

Ok, thanks! :)

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

2 participants