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

Unnecessarily re-initializing tabs on mobile devices #1

Open
steveosoule opened this issue Jul 26, 2016 · 1 comment
Open

Unnecessarily re-initializing tabs on mobile devices #1

steveosoule opened this issue Jul 26, 2016 · 1 comment
Assignees

Comments

@steveosoule
Copy link

On some mobile devices, scrolling can a window resize event to fire. The plugin then responds and unnecessarily redraws the tabs. Then, when the tabs are redrawn, the original .current tab doesn't stay open.

Something like this could help the base.resize() function from unnecessarily re-initializing:

// ...
base.cachedViewport = 0;

base.resize = function () {
    base.viewport = $(window).outerWidth();

    if( base.viewport === base.cachedViewport ){
        return;
    }
    base.cachedViewport = base.viewport;

    if (base.viewport <= base.options.breakpoint && base.options.layout == 'auto') {
        base.$el.removeClass('tabs');
        base.$el.addClass('accordion');
    }
    else if (base.viewport > base.options.breakpoint && base.options.layout == 'auto') {
        base.$el.removeClass('accordion');
        base.$el.addClass('tabs');
    };
    base.init();
};

// Run Functions
base.init();
base.navigation();
$(window).on('resize', function () {
    base.resize();
});
// ...

I didn't really look at how to fix the part where when the tabs are re-initialized the .current tab changes.

@influxweb
Copy link
Owner

Thanks for the bug report and coding details; I'll take a look into it. I've been working on a rewrite of this script as well as a superceding version which doesn't require JavaScript.

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