Skip to content

Commit

Permalink
fix horizontal accordion animation problems
Browse files Browse the repository at this point in the history
  • Loading branch information
bradrobertson committed Sep 8, 2011
1 parent e4995ac commit 4a5a21c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
29 changes: 17 additions & 12 deletions src/tabs/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,24 @@

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

var nextPane = this.getPanes().eq(i);

// store original width of a pane into memory
w || ( w = this.getPanes().eq(0).width() );

// set current pane's width to zero
this.getCurrentPane().animate({width: 0}, function(){
$(this).hide();
});

// grow opened pane to it's original width
this.getPanes().eq(i).animate({width: w}, function() {
$(this).show();
done.call();
});
nextPane.show(); // hidden by default

// set current pane's width to zero
// animate next pane at the same time for smooth animation
this.getCurrentPane().animate({width: 0}, {
step: function(now){
nextPane.css("width", w-now);
},
complete: function(){
$(this).hide();
done.call();
}
});
});


Expand Down Expand Up @@ -161,10 +165,10 @@
// call the effect
effects[conf.effect].call(self, i, function() {

current = i;
// onClick callback
e.type = "onClick";
trigger.trigger(e, [i]);
current = i;
trigger.trigger(e, [i]);
});

// default behaviour
Expand Down Expand Up @@ -254,6 +258,7 @@

} else {
if (conf.initialIndex === 0 || conf.initialIndex > 0) {
current = conf.initialIndex; // ensure that current is set properly
self.click(conf.initialIndex);
}
}
Expand Down
6 changes: 3 additions & 3 deletions test/tabs/accordion-horizontal.htm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<!-- accordion header #1 -->
<div class="blok"></div>

<div class="pane" style="width:200px; display:block">
<div class="pane 0" style="width:200px; display:block">
<h3>First pane</h3>
<p>
Consectetur adipiscing elit. Praesent bibendum eros ac nulla. Integer vel lacus ac neque viverra.
Expand All @@ -18,7 +18,7 @@ <h3>First pane</h3>

<div class="blok"></div>

<div class="pane">
<div class="pane 1">
<h3>Second pane</h3>
<p>
Cras diam. Donec dolor lacus, vestibulum at, varius in, mollis id, dolor. Aliquam erat volutpat.
Expand All @@ -27,7 +27,7 @@ <h3>Second pane</h3>

<div class="blok"></div>

<div class="pane">
<div class="pane 2">
<h3>Third pane</h3>
<p>
Non lectus lacinia egestas. Nulla hendrerit, felis quis elementum viverra, purus felis egestas magna.
Expand Down
1 change: 1 addition & 0 deletions test/tabs/css/horizontal.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
float:left;
display:none;
margin-right:10px;
overflow:hidden;
}

/* content inside a pane should have fixed width */
Expand Down

0 comments on commit 4a5a21c

Please sign in to comment.