From b3142d613806ed243947ddbf304a33f6e97219b5 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Fri, 26 Feb 2021 22:24:36 -0700 Subject: [PATCH] Offset read receipt start positions by 1px As mentioned in 208faf6d46e30a77db7f4dd4b6d6a2bd2dba138f, the velocity-animate update causes read receipts to occasionally show up 14px to the right of where they should be. This is because the read receipt width is 14px, and velocity-animate will *not* translate `left` if it isn't changing. Unfortunately, it's smart enough to realize that `-0px` is `0px`, so we end up having to specify `1px`. The comment already mentions it, but this should have no perceived effect for the user. During development I could not tell if the 1px was being applied during the animation, implying that it's a meaningless value. It's a bit unfortunate for those who know that it's translating left by 1px, but hopefully they'll be able to unsee that in time. --- src/components/views/rooms/ReadReceiptMarker.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/views/rooms/ReadReceiptMarker.js b/src/components/views/rooms/ReadReceiptMarker.js index c19247ef5a..f5c676b841 100644 --- a/src/components/views/rooms/ReadReceiptMarker.js +++ b/src/components/views/rooms/ReadReceiptMarker.js @@ -155,7 +155,13 @@ export default class ReadReceiptMarker extends React.Component { // then shift to the rightmost column, // and then it will drop down to its resting position - startStyles.push({ top: startTopOffset+'px', left: '0px' }); + // + // XXX: We use a `left: 1px` to trick velocity-animate into actually animating. This + // is a very annoying bug where if it thinks there's no change to `left` then it'll + // skip applying it, thus making our read receipt at +14px instead of +0px like it + // should be. This does cause 1px of drift for read receipts, however nobody should + // notice this while it's also falling. + startStyles.push({ top: startTopOffset+'px', left: '1px' }); enterTransitionOpts.push({ duration: bounce ? Math.min(Math.log(Math.abs(startTopOffset)) * 200, 3000) : 300, easing: bounce ? 'easeOutBounce' : 'easeOutCubic',