Created
February 16, 2018 06:28
-
-
Save imarkdesigns/4035c1795b1c7964fafb2b06d1b21221 to your computer and use it in GitHub Desktop.
Uikit 3 Accordion + ScrollTo #uikit #jquery
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
// Script originally made by @zzseba78 | |
// Using JQuery | |
var $ac = $('#accordion'); | |
UIkit.accordion($ac, { | |
multiple: false, | |
collapsible: true, | |
duration: 300, | |
transition:"easeInOut" | |
}); | |
$('a.uk-accordion-title').on('click', function() { | |
// Get the current index | |
var scrollEl = $(this); | |
// Scroll to element with timeout to let content show | |
setTimeout(function(){ | |
var $scrolling = UIkit.scroll({ duration: 300, offset: 20 }); | |
$scrolling.scrollTo(scrollEl); | |
}, 320); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment