Last active
October 27, 2020 08:11
-
-
Save wplit/58a1c848f25f053748a7acc1e36ac86e to your computer and use it in GitHub Desktop.
link to accordion item inside Pro Accordion component with hashlink from another page
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
jQuery(document).ready(function($) { | |
// open the accordion if hash link | |
var hash = window.location.hash; | |
if (hash) { | |
var element = $(hash); | |
setTimeout(function() { | |
// Only if element is found and is part of a Pro Accordion item | |
if (element.length && element.parent('.oxy-pro-accordion_item').length) { | |
// Open up the accordion | |
element.trigger('click'); | |
// scroll to the element. | |
$([document.documentElement, document.body]).animate({ | |
scrollTop: $(hash).offset().top - 100 | |
}, 1000); | |
} | |
}, 1000); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment