Skip to content

Commit b9a35fb

Browse files
committed
more horizontal accordion changes
1 parent 4a5a21c commit b9a35fb

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

src/tabs/tabs.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,24 +94,28 @@
9494

9595
$.tools.tabs.addEffect("horizontal", function(i, done) {
9696

97-
var nextPane = this.getPanes().eq(i);
98-
97+
var nextPane = this.getPanes().eq(i),
98+
currentPane = this.getCurrentPane();
99+
99100
// store original width of a pane into memory
100101
w || ( w = this.getPanes().eq(0).width() );
101102

102103
nextPane.show(); // hidden by default
103104

104-
// set current pane's width to zero
105-
// animate next pane at the same time for smooth animation
106-
this.getCurrentPane().animate({width: 0}, {
105+
// animate current pane's width to zero
106+
// animate next pane's width at the same time for smooth animation
107+
currentPane.animate({width: 0}, {
107108
step: function(now){
108109
nextPane.css("width", w-now);
109110
},
110111
complete: function(){
111112
$(this).hide();
112113
done.call();
113114
}
114-
});
115+
});
116+
// Dirty hack... onLoad, currentPant will be empty and nextPane will be the first pane
117+
// If this is the case, manually run callback since the animation never occured
118+
if (!currentPane.length){ done.call(); }
115119
});
116120

117121

@@ -134,7 +138,7 @@
134138
$.extend(this, {
135139
click: function(i, e) {
136140

137-
var tab = tabs.eq(i);
141+
var tab = tabs.eq(i);
138142

139143
if (typeof i == 'string' && i.replace("#", "")) {
140144
tab = tabs.filter("[href*=" + i.replace("#", "") + "]");
@@ -164,7 +168,6 @@
164168

165169
// call the effect
166170
effects[conf.effect].call(self, i, function() {
167-
168171
current = i;
169172
// onClick callback
170173
e.type = "onClick";
@@ -258,7 +261,6 @@
258261

259262
} else {
260263
if (conf.initialIndex === 0 || conf.initialIndex > 0) {
261-
current = conf.initialIndex; // ensure that current is set properly
262264
self.click(conf.initialIndex);
263265
}
264266
}

test/tabs/accordion-horizontal.htm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<!-- accordion header #1 -->
1010
<div class="blok"></div>
1111

12-
<div class="pane 0" style="width:200px; display:block">
12+
<div class="pane 0" style="width:200px;">
1313
<h3>First pane</h3>
1414
<p>
1515
Consectetur adipiscing elit. Praesent bibendum eros ac nulla. Integer vel lacus ac neque viverra.

0 commit comments

Comments
 (0)