Skip to content

Instantly share code, notes, and snippets.

@sonichandni
Created January 18, 2023 09:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sonichandni/06b0124f274b3af862b2343af0e01974 to your computer and use it in GitHub Desktop.
Save sonichandni/06b0124f274b3af862b2343af0e01974 to your computer and use it in GitHub Desktop.
scroll div
function scroll_screen(){
if ($('.error-color')) {
// old code for full screen scrolling
// var content_class = "callon_content";
// $('.'+content_class).animate({
// scrollTop: $('.error-color').offset().top
// }, 2000);
// new code to scroll inside middle div
let errorElement = document.getElementsByClassName('error-color')[0];
errorElement.scrollIntoView({
behavior: "smooth"
});
}
}
function scroll_screen_options(errorClass = 'error-color'){
if ($(`.${errorClass}`)) {
// old code for full screen scrolling
// var scroll_pos = $(`.${errorClass}`).position().top;
// $( "div.callon_content" ).scrollTop( scroll_pos - 70 );
// new code to scroll inside middle div
let errorElement = document.getElementsByClassName(errorClass)[0];
errorElement.scrollIntoView({
behavior: "smooth"
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment