Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. //Scroll to form on button click and focus on first input
  2. $('#up-to-form').on('click', function(e) {
  3. e.preventDefault();
  4. $('html, body').animate({
  5. scrollTop: $('.form-container').offset().top - 20
  6. }, 'slow');
  7. $('.form-container form input').first().focus();
  8. });
  9.  
  10. //Make form fixed so it stays in view on desktop viewport
  11. $(window).scroll(function() {
  12. var scroll = $(window).scrollTop();
  13.  
  14. if (scroll >= 50) {
  15. $(".form-fixed-wrapper").addClass("fixed-scroll");
  16. }
  17. if (scroll <= 50) {
  18. $(".form-fixed-wrapper").removeClass("fixed-scroll");
  19. }
  20. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement