Commit d0ba90c1 by Qiang Xue

better auto scrolling.

parent 5e9c8cb7
...@@ -143,7 +143,11 @@ ...@@ -143,7 +143,11 @@
}); });
updateSummary($form, messages); updateSummary($form, messages);
if (errors.length) { if (errors.length) {
$(window).scrollTop($form.find(errors.join(',')).first().offset().top); var top = $form.find(errors.join(',')).first().offset().top;
var wtop = $(window).scrollTop();
if (top < wtop || top > wtop + $(window).height) {
$(window).scrollTop(top);
}
} else { } else {
data.validated = true; data.validated = true;
var $button = data.submitObject || $form.find(':submit:first'); var $button = data.submitObject || $form.find(':submit:first');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment