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

Commit b6e3176

Browse files
committed
Fix stickers briefly being 2x the size
fixupHeight was the only thing actually fixing the size of the sticker image to be the size we want it rather than the pixel size of the image, and this was only getting run after the image loaded, causing a flash of 2x image.
1 parent ac297d1 commit b6e3176

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/components/views/messages/MStickerBody.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,16 @@ export default class MStickerBody extends MImageBody {
107107
placeholderFixupHeight = content.info.h + 'px';
108108
}
109109

110+
// The pixel size of sticker images is generally larger than their intended display
111+
// size so they render at native reolution on HiDPI displays. We therefore need to
112+
// explicity set the size so they render at the intended size.
113+
// XXX: This will be clobberred when we run fixupHeight(), but we need to do it
114+
// here otherwise the stickers are momentarily displayed at the pixel size.
115+
const imageStyle = {
116+
height: content.info.h,
117+
// leave the browser the calculate the width automatically
118+
};
119+
110120
placeholderSize = placeholderSize + 'px';
111121

112122
// Body 'ref' required by MImageBody
@@ -132,6 +142,7 @@ export default class MStickerBody extends MImageBody {
132142
<img
133143
className={'mx_MStickerBody_image ' + this.state.imageClasses}
134144
src={contentUrl}
145+
style={imageStyle}
135146
ref='image'
136147
alt={content.body}
137148
onLoad={this._onImageLoad}

0 commit comments

Comments
 (0)