Skip to content

Commit

Permalink
DEV-649: Fixed auto scrolling to reply field
Browse files Browse the repository at this point in the history
  • Loading branch information
jjtykkyl committed May 14, 2020
1 parent c5f59d8 commit 73f658d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
enableAttachments: true,
enableHashtags: true,
enablePinging: true,
scrollContainer: $(window),
searchUsers: function(term, success, error) {
setTimeout(function() {
success(usersArray.filter(function(user) {
Expand Down
12 changes: 5 additions & 7 deletions js/jquery-comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -1128,15 +1128,13 @@

// Move cursor to end
var textarea = replyField.find('.textarea');
this.moveCursorToEnd(textarea)
this.moveCursorToEnd(textarea);
textarea.focus();

// Make sure the reply field will be displayed
var scrollTop = this.options.scrollContainer.scrollTop();
var endOfReply = scrollTop + replyField.position().top + replyField.outerHeight();
var endOfScrollable = scrollTop + this.options.scrollContainer.outerHeight();
if(endOfReply > endOfScrollable) {
var newScrollTop = scrollTop + (endOfReply - endOfScrollable);
this.options.scrollContainer.scrollTop(newScrollTop);
var minScrollTop = replyField.position().top + replyField.outerHeight() - this.options.scrollContainer.outerHeight();
if(this.options.scrollContainer.scrollTop() < minScrollTop) {
this.options.scrollContainer.scrollTop(minScrollTop);
}
}
},
Expand Down

0 comments on commit 73f658d

Please sign in to comment.