Created
January 18, 2023 09:01
-
-
Save sonichandni/06b0124f274b3af862b2343af0e01974 to your computer and use it in GitHub Desktop.
scroll div
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
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