Skip to content

Mobile platforms much more responsive #155

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions lib/jquery.easytabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
panelClass: "",
cache: true,
event: 'click',
touchevent: 'touchend',
panelContext: $container
},

Expand All @@ -60,6 +61,7 @@
normal: 400,
slow: 600
},
isTouchDevice = false,

// Shorthand variable so that we don't need to call
// plugin.settings throughout the plugin code
Expand All @@ -73,6 +75,7 @@

plugin.settings = settings = $.extend({}, defaults, options);
settings.bind_str = settings.event+".easytabs";
settings.touchbind_str = settings.touchevent+".easytabs";

// Add jQuery UI's crazy class names to markup,
// so that markup will match theme CSS
Expand Down Expand Up @@ -458,9 +461,10 @@
.addClass(settings.panelActiveClass);

$defaultTab
.addClass(settings.tabActiveClass)
.children()
.addClass(settings.tabActiveClass);
.addClass(settings.tabActiveClass);
//Do not add class to children
//.children()
//.addClass(settings.tabActiveClass);
}

// Fire event when the plugin is initialised
Expand All @@ -470,8 +474,15 @@
// Bind tab-select funtionality to namespaced click event, called by
// init
var bindToTabClicks = function() {
plugin.tabs.children("a").bind(settings.bind_str, function(e) {

plugin.tabs.children("a").bind(settings.bind_str+" "+settings.touchbind_str, function(e) {

// If this is a touch device, don't listen to clicks after this
if( !isTouchDevice && event.type === "touchend" )
{
isTouchDevice = true;
plugin.tabs.children("a").unbind( settings.bind_str );
}

// Stop cycling when a tab is clicked
settings.cycle = false;

Expand Down Expand Up @@ -578,8 +589,8 @@
// Change the active tab *first* to provide immediate feedback when the user clicks
plugin.tabs.filter("." + settings.tabActiveClass).removeClass(settings.tabActiveClass).children().removeClass(settings.tabActiveClass);
plugin.tabs.filter("." + settings.collapsedClass).removeClass(settings.collapsedClass).children().removeClass(settings.collapsedClass);
$clicked.parent().addClass(settings.tabActiveClass).children().addClass(settings.tabActiveClass);

$clicked.parent().addClass(settings.tabActiveClass);//.children().addClass(settings.tabActiveClass);
//Do not add class to the children
plugin.panels.filter("." + settings.panelActiveClass).removeClass(settings.panelActiveClass);
$targetPanel.addClass(settings.panelActiveClass);

Expand Down
Loading