Skip to content

Instantly share code, notes, and snippets.

@yahyaahrika
Created June 23, 2021 15:37
Show Gist options
  • Save yahyaahrika/27dc4580228b9179e170474da1613fb2 to your computer and use it in GitHub Desktop.
Save yahyaahrika/27dc4580228b9179e170474da1613fb2 to your computer and use it in GitHub Desktop.
Scroll animation to div specifique
$(document).on('click', 'a[href^="#"]', function (e) {
// target element id
var id = $(this).attr('href');
// target element
var $id = $(id);
if ($id.length === 0) {
return;
}
// prevent standard hash navigation (avoid blinking in IE)
e.preventDefault();
// top position relative to the document
var pos = $id.offset().top;
// animated top scrolling
$('body, html').animate({ scrollTop: pos });
console.log($(id))
$('.dataTables_wrapper').css({ 'position': 'unset', 'animation': 'unset' });
$(id).next('.dataTables_wrapper').css({ 'position': 'relative', 'animation': 'animateright 1.5s' })
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment