better fix for not scrolling textarea

This commit is contained in:
Toks
2013-05-14 08:53:50 -04:00
parent 54ca90a381
commit 968c1d14f6
2 changed files with 8 additions and 3 deletions

View File

@@ -226,9 +226,7 @@
Danbooru.RelatedTag.process_artist(Danbooru.RelatedTag.recent_artist); Danbooru.RelatedTag.process_artist(Danbooru.RelatedTag.recent_artist);
} }
if ($(window).scrollTop() <= $field.offset().top) { $field.focusWithoutScroll();
$field.focus();
}
e.preventDefault(); e.preventDefault();
} }

View File

@@ -103,4 +103,11 @@
this.selectRange(this.val().length, this.val().length); this.selectRange(this.val().length, this.val().length);
return this; return this;
} }
$.fn.focusWithoutScroll = function(){
var x = window.scrollX;
var y = window.scrollY;
this.focus();
window.scrollTo(x, y);
};
})(); })();