Skip to content

Instantly share code, notes, and snippets.

@Dartv
Created October 3, 2016 13:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dartv/4012ede053219f75e324c3f68a829f7d to your computer and use it in GitHub Desktop.
Save Dartv/4012ede053219f75e324c3f68a829f7d to your computer and use it in GitHub Desktop.
const $chat = $('.chat-content');
const $message = $(ReactDOM.findDOMNode(component));
const msgOffset = $message.offset().top;
// center the linked message in the chat box
const elHeight = $message.height();
const chatHeight = $chat.height();
const offset = msgOffset - ((chatHeight / 2) - (elHeight / 2));
$chat.scrollTop(offset);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment