Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 5665a0e

Browse files
author
Luke Barnard
committed
Fix scroll jump on image decryption
`onWidgetLoad` is now being called when an image has been decrypted so that the ScrollPanel maintains its scroll position (whether it's stuckAtBottom or not). This attempts to fix element-hq/element-web#2624
1 parent 3aa1e0d commit 5665a0e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/components/views/messages/MImageBody.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ module.exports = React.createClass({
3232
propTypes: {
3333
/* the MatrixEvent to show */
3434
mxEvent: React.PropTypes.object.isRequired,
35+
36+
/* called when the image has loaded */
37+
onWidgetLoad: React.PropTypes.func.isRequired,
3538
},
3639

3740
getInitialState: function() {
@@ -123,6 +126,7 @@ module.exports = React.createClass({
123126
decryptedUrl: contentUrl,
124127
decryptedThumbnailUrl: thumbnailUrl,
125128
});
129+
this.props.onWidgetLoad();
126130
});
127131
}).catch((err) => {
128132
console.warn("Unable to decrypt attachment: ", err);
@@ -186,11 +190,12 @@ module.exports = React.createClass({
186190
<span className="mx_MImageBody" ref="body">
187191
<div className="mx_MImageBody_thumbnail" ref="image" style={{
188192
"display": "flex",
189-
"align-items": "center",
190-
"justify-items": "center",
193+
"alignItems": "center",
191194
"width": "100%",
192195
}}>
193-
<img src="img/spinner.gif" alt={content.body} width="16" height="16"/>
196+
<img src="img/spinner.gif" alt={content.body} width="32" height="32" style={{
197+
"margin": "auto",
198+
}}/>
194199
</div>
195200
</span>
196201
);

0 commit comments

Comments
 (0)