mirror of https://github.com/vector-im/riot-web
Fix centering issue with sticker placeholder (#8404)
parent
e3735311ab
commit
f85e178fc1
|
@ -33,3 +33,10 @@ limitations under the License.
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.mx_MStickerBody_placeholder {
|
||||||
|
// centering
|
||||||
|
position: absolute;
|
||||||
|
left: calc(50% - 40px);
|
||||||
|
top: calc(50% - 40px);
|
||||||
|
}
|
||||||
|
|
|
@ -138,7 +138,7 @@ export default class MImageBody extends React.Component<IBodyProps, IState> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private onImageEnter = (e: React.MouseEvent<HTMLImageElement>): void => {
|
protected onImageEnter = (e: React.MouseEvent<HTMLImageElement>): void => {
|
||||||
this.setState({ hover: true });
|
this.setState({ hover: true });
|
||||||
|
|
||||||
if (!this.state.showImage || !this.state.isAnimated || SettingsStore.getValue("autoplayGifs")) {
|
if (!this.state.showImage || !this.state.isAnimated || SettingsStore.getValue("autoplayGifs")) {
|
||||||
|
@ -148,7 +148,7 @@ export default class MImageBody extends React.Component<IBodyProps, IState> {
|
||||||
imgElement.src = this.state.contentUrl;
|
imgElement.src = this.state.contentUrl;
|
||||||
};
|
};
|
||||||
|
|
||||||
private onImageLeave = (e: React.MouseEvent<HTMLImageElement>): void => {
|
protected onImageLeave = (e: React.MouseEvent<HTMLImageElement>): void => {
|
||||||
this.setState({ hover: false });
|
this.setState({ hover: false });
|
||||||
|
|
||||||
if (!this.state.showImage || !this.state.isAnimated || SettingsStore.getValue("autoplayGifs")) {
|
if (!this.state.showImage || !this.state.isAnimated || SettingsStore.getValue("autoplayGifs")) {
|
||||||
|
|
|
@ -39,11 +39,19 @@ export default class MStickerBody extends MImageBody {
|
||||||
return <div className="mx_MStickerBody_wrapper" onClick={onClick}> { children } </div>;
|
return <div className="mx_MStickerBody_wrapper" onClick={onClick}> { children } </div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Placeholder to show in place of the sticker image if
|
// Placeholder to show in place of the sticker image if img onLoad hasn't fired yet.
|
||||||
// img onLoad hasn't fired yet.
|
|
||||||
protected getPlaceholder(width: number, height: number): JSX.Element {
|
protected getPlaceholder(width: number, height: number): JSX.Element {
|
||||||
if (this.props.mxEvent.getContent().info?.[BLURHASH_FIELD]) return super.getPlaceholder(width, height);
|
if (this.props.mxEvent.getContent().info?.[BLURHASH_FIELD]) return super.getPlaceholder(width, height);
|
||||||
return <img src={require("../../../../res/img/icons-show-stickers.svg").default} width="75" height="75" />;
|
return (
|
||||||
|
<img
|
||||||
|
className="mx_MStickerBody_placeholder"
|
||||||
|
src={require("../../../../res/img/icons-show-stickers.svg").default}
|
||||||
|
width="80"
|
||||||
|
height="80"
|
||||||
|
onMouseEnter={this.onImageEnter}
|
||||||
|
onMouseLeave={this.onImageLeave}
|
||||||
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tooltip to show on mouse over
|
// Tooltip to show on mouse over
|
||||||
|
|
Loading…
Reference in New Issue