From f7fe871fee8f9b733345ebc49977686b063adc3b Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 19 Nov 2015 11:33:15 +0000 Subject: [PATCH] If read receipts avatar isn't on screen, animate it from the top of the screen. --- src/skins/vector/views/molecules/EventTile.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/skins/vector/views/molecules/EventTile.js b/src/skins/vector/views/molecules/EventTile.js index 1e4c9a63..c5482b50 100644 --- a/src/skins/vector/views/molecules/EventTile.js +++ b/src/skins/vector/views/molecules/EventTile.js @@ -131,11 +131,15 @@ module.exports = React.createClass({ var oldAvatarDomNode = document.getElementById('mx_readAvatar'+member.userId); var startStyles = []; var enterTransitionOpts = []; - if (oldAvatarDomNode && this.readAvatarRect) { - var oldRect = oldAvatarDomNode.getBoundingClientRect(); - var topOffset = oldRect.top - this.readAvatarRect.top; + var oldNodeTop = -15; // For avatars that weren't on screen, act as if they were just off the top + if (oldAvatarDomNode) { + oldNodeTop = oldAvatarDomNode.getBoundingClientRect().top; + } - if (oldAvatarDomNode.style.left !== '0px') { + if (this.readAvatarRect) { + var topOffset = oldNodeTop - this.readAvatarRect.top; + + if (oldAvatarDomNode && oldAvatarDomNode.style.left !== '0px') { var leftOffset = oldAvatarDomNode.style.left; // start at the old height and in the old h pos startStyles.push({ top: topOffset, left: leftOffset });