Skip to content

Instantly share code, notes, and snippets.

@ryumada
Last active November 13, 2020 06:46
Show Gist options
  • Save ryumada/29672e2dd9e7d4f0947612eff596c4f0 to your computer and use it in GitHub Desktop.
Save ryumada/29672e2dd9e7d4f0947612eff596c4f0 to your computer and use it in GitHub Desktop.
this is jquery script to scroll on swal modal close.
Swal.fire({
title: 'Form Validation Error',
html: "Please fill the required input form.",
icon: 'warning',
showCancelButton: false,
// confirmButtonColor: '#99FF99',
// cancelButtonColor: '#d33',
confirmButtonText: 'Ok, I wiil check it.',
allowOutsideClick: false,
allowEscapeKey: false,
allowEnterKey: false
}).then((result) => {
if (result.value) {
var el = $('select#entityInput');
var elOffset = el.offset().top;
var elHeight = el.height();
var windowHeight = $(window).height();
var offset;
if (elHeight < windowHeight) {
offset = elOffset - ((windowHeight / 2) - (elHeight / 2));
}
else {
offset = elOffset;
}
$([document.documentElement, document.body]).animate({ //for animation
scrollTop: offset
}, 750);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment