javascript - jQuery scroll page so cursor stays at the "logical center" -


i have huge html form , near 350 controls take 5-6 times of user screen height. user starts completing each input field beginning of page , goes on. once cursor rich near bottom of screen user must able see next input fields here problem : want avoid scrollbar usage. want set "margines" ( 200px each page side )

if user clicks control near screen edge, here mechanism must work also

i'm looking jquery solution

playing around jquery.scrollto, can't figure out how embed logic code.

this should it

http://jsfiddle.net/jswnk/

$(document).ready(function() {      $('input').focus(function() {          var padding = 100; // desired page "padding"          var lbound = $(this).offset().top - $(window).height() + padding;         var ubound = $(this).offset().top - padding;          if ($(window).scrolltop() < lbound)             $(window).scrolltop(lbound);         else if ($(window).scrolltop() > ubound)             $(window).scrolltop(ubound);      }); }); ​ 

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -