Skip to content

Instantly share code, notes, and snippets.

@imarkdesigns
Created February 16, 2018 06:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imarkdesigns/4035c1795b1c7964fafb2b06d1b21221 to your computer and use it in GitHub Desktop.
Save imarkdesigns/4035c1795b1c7964fafb2b06d1b21221 to your computer and use it in GitHub Desktop.
Uikit 3 Accordion + ScrollTo #uikit #jquery
// 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