SplitPanel: don't toggle again while toggle animation is running

This commit is contained in:
rlx 2013-07-28 23:33:12 +00:00
parent 34894f8d29
commit 7a20c4ca05

View file

@ -305,11 +305,15 @@ Ox.SplitPanel = function(options, self) {
// FIXME: isn't 'toggle' reserved by jQuery?
that.toggle = function(id) {
// one can pass pos instead of id
if (self.toggling) {
return false;
}
var pos = Ox.isNumber(id) ? id : getPositionById(id),
element = self.options.elements[pos],
value = parseInt(that.css(self.edges[pos == 0 ? 0 : 1]), 10)
+ element.element[self.dimensions[0]]() * (element.collapsed ? 1 : -1),
animate = {};
self.toggling = true;
animate[self.edges[pos == 0 ? 0 : 1]] = value;
that.animate(animate, 250, function() {
element.collapsed = !element.collapsed;
@ -321,6 +325,7 @@ Ox.SplitPanel = function(options, self) {
element.element.triggerEvent('resize', {
size: element.element[self.dimensions[0]]()
});
self.toggling = false;
});
};