diff --git a/.DS_Store b/.DS_Store index ef07dc3..ddf4d26 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/index.html b/index.html index 81ae67c..362dad3 100644 --- a/index.html +++ b/index.html @@ -7,14 +7,12 @@ - - @@ -93,7 +91,7 @@
- +
diff --git a/js/Weight Calculation Script-Edited-Jquery-V4.js b/js/Weight Calculation Script-Edited-Jquery-V4.js index 49f43bb..267bfb0 100644 --- a/js/Weight Calculation Script-Edited-Jquery-V4.js +++ b/js/Weight Calculation Script-Edited-Jquery-V4.js @@ -106,50 +106,33 @@ // The optional number (800) specifies the number of milliseconds it takes to scroll to the specified area $('html, body').animate({ scrollTop: $(hash).offset().top - }, 800, function(){ + }, 500, function(){ // Add hash (#) to URL when done scrolling (default click behavior) window.location.hash = hash; }); } // End if }); - }); - //Saves scroll position on focus and restores - var savedScrollTop + //Saves scroll position on focus and restores + var savedScrollTop; function saveScroll() { - var savedScrollTop = jQuery(document).scrollTop(); // save scroll position + savedScrollTop = jQuery(document).scrollTop(); console.log(savedScrollTop); } - function restoreScroll(savedScrollTop){ - jQuery("html, body").animate({ - scrollTop: savedScrollTop - }, 800).offset().top; - } - -//Failed scroll restore functions - - // jQuery("#Weight").blur(function(event) { - // $("html, body").animate({ - // scrollTop: savedScrollTop - // }, 800).offset().top; - // }); - - - /*function restoreScroll() { - $("a").on('click', function(event) { - - jQuery(window).scrollTop(savedScrollTop);*/ -/* window.scrollTo({ - top: "savedScrollTop", - behavior: "smooth" - }); // restore it*/ + function restoreScroll(){ + jQuery("html, body").animate({ + scrollTop: savedScrollTop + }, 250).offset().top; + } - - - /*var savedScrollTop = $(document).scrollTop(); // save scroll position - - $(document).scrollTop(savedScrollTop ); // restore it*/ -// }); \ No newline at end of file + //jQuery event watching + jQuery(".input-weight").on("focus", function(){ + saveScroll(); + }); + jQuery(".input-weight").on('blur', function(){ + restoreScroll() + }); + });