apply portrait/landscape/quadrat format to playing gif to always display it in best possible way
Этот коммит содержится в:
@@ -15,7 +15,7 @@ export default class FileAttachment extends React.Component {
|
|||||||
this.addBackgroundImage = this.addBackgroundImage.bind(this);
|
this.addBackgroundImage = this.addBackgroundImage.bind(this);
|
||||||
|
|
||||||
this.canSetState = false;
|
this.canSetState = false;
|
||||||
this.state = {fileSize: -1, mime: '', playing: false, loading: false};
|
this.state = {fileSize: -1, mime: '', playing: false, loading: false, format: ''};
|
||||||
}
|
}
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.loadFiles();
|
this.loadFiles();
|
||||||
@@ -93,7 +93,21 @@ export default class FileAttachment extends React.Component {
|
|||||||
this.setState({loading: true});
|
this.setState({loading: true});
|
||||||
img.load(fileUrl);
|
img.load(fileUrl);
|
||||||
img.onload = () => {
|
img.onload = () => {
|
||||||
this.setState({playing: true, loading: false});
|
var state = {playing: true, loading: false};
|
||||||
|
|
||||||
|
switch (true) {
|
||||||
|
case img.width > img.height:
|
||||||
|
state.format = 'landscape';
|
||||||
|
break;
|
||||||
|
case img.height > img.width:
|
||||||
|
state.format = 'portrait';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
state.format = 'quadrat';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setState(state);
|
||||||
|
|
||||||
// keep displaying background image for a short moment while browser is
|
// keep displaying background image for a short moment while browser is
|
||||||
// loading gif, to prevent white background flashing through
|
// loading gif, to prevent white background flashing through
|
||||||
@@ -164,7 +178,7 @@ export default class FileAttachment extends React.Component {
|
|||||||
if (this.state.playing) {
|
if (this.state.playing) {
|
||||||
loadedFile = (
|
loadedFile = (
|
||||||
<img
|
<img
|
||||||
className='file__loaded'
|
className={'file__loaded ' + this.state.format}
|
||||||
src={fileUrl}
|
src={fileUrl}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -150,8 +150,13 @@
|
|||||||
margin-top: -16px;
|
margin-top: -16px;
|
||||||
}
|
}
|
||||||
.file__loaded {
|
.file__loaded {
|
||||||
height: 100px;
|
|
||||||
max-width: initial;
|
max-width: initial;
|
||||||
|
&.landscape, &.quadrat {
|
||||||
|
height: 100px;
|
||||||
|
}
|
||||||
|
&.portrait {
|
||||||
|
width: 120px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
&:hover .file-playback-controls.stop {
|
&:hover .file-playback-controls.stop {
|
||||||
@include opacity(1);
|
@include opacity(1);
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user