Last active
December 17, 2015 09:58
-
-
Save danielbehrendt/5590774 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*\ | |
Animate collapsible set; | |
\*/ | |
$(document).one("pagebeforechange", function () { | |
// animation speed; | |
var animationSpeed = 200; | |
function animateCollapsibleSet(elm) { | |
// can attach events only one time, otherwise we create infinity loop; | |
elm.one("expand", function () { | |
// hide the other collapsibles first; | |
$(this).parent().find(".ui-collapsible-content").not(".ui-collapsible-content-collapsed").trigger("collapse"); | |
// animate show on collapsible; | |
$(this).find(".ui-collapsible-content").slideDown(animationSpeed, function () { | |
// trigger original event and attach the animation again; | |
animateCollapsibleSet($(this).parent().trigger("expand")); | |
}); | |
// we do our own call to the original event; | |
return false; | |
}).one("collapse", function () { | |
// animate hide on collapsible; | |
$(this).find(".ui-collapsible-content").slideUp(animationSpeed, function () { | |
// trigger original event; | |
$(this).parent().trigger("collapse"); | |
}); | |
// we do our own call to the original event; | |
return false; | |
}); | |
} | |
// init; | |
animateCollapsibleSet($("[data-role='collapsible-set'] > [data-role='collapsible']")); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment