Last active
November 13, 2020 06:46
-
-
Save ryumada/29672e2dd9e7d4f0947612eff596c4f0 to your computer and use it in GitHub Desktop.
this is jquery script to scroll on swal modal close.
This file contains hidden or 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
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