Horizontally align images if image height > image width
Этот коммит содержится в:
@@ -94,16 +94,28 @@ export default class FileAttachment extends React.Component {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
playGif(e, fileUrl) {
|
playGif(e, filename) {
|
||||||
var img = new Image();
|
var img = new Image();
|
||||||
|
var fileUrl = utils.getFileUrl(filename);
|
||||||
|
|
||||||
this.setState({loading: true});
|
this.setState({loading: true});
|
||||||
img.load(fileUrl);
|
img.load(fileUrl);
|
||||||
img.onload = () => this.setState({playing: true, loading: false});
|
img.onload = () => {
|
||||||
|
this.setState({playing: true, loading: false});
|
||||||
|
|
||||||
|
// keep displaying background image for a short moment while browser is
|
||||||
|
// loading gif, to prevent white background flashing through
|
||||||
|
setTimeout(() => this.removeBackgroundImage.bind(this)(filename), 100);
|
||||||
|
};
|
||||||
img.onError = () => this.setState({loading: false});
|
img.onError = () => this.setState({loading: false});
|
||||||
|
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
}
|
}
|
||||||
|
removeBackgroundImage(name) {
|
||||||
|
if (name in this.refs) {
|
||||||
|
$(ReactDOM.findDOMNode(this.refs[name])).css('background-image', 'initial');
|
||||||
|
}
|
||||||
|
}
|
||||||
render() {
|
render() {
|
||||||
var filename = this.props.filename;
|
var filename = this.props.filename;
|
||||||
|
|
||||||
@@ -118,7 +130,7 @@ export default class FileAttachment extends React.Component {
|
|||||||
playButton = (
|
playButton = (
|
||||||
<div
|
<div
|
||||||
className='file-play-button'
|
className='file-play-button'
|
||||||
onClick={(e) => this.playGif(e, fileUrl)}
|
onClick={(e) => this.playGif(e, filename)}
|
||||||
>
|
>
|
||||||
{"►"}
|
{"►"}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -135,6 +135,7 @@
|
|||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
text-align: center;
|
||||||
&.small {
|
&.small {
|
||||||
background-position: center;
|
background-position: center;
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user