Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
fix/2175: shows loading text while image loads (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
nihakhanna committed Apr 4, 2017
1 parent 1c74e71 commit c53297f
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion server/src/pages/shot/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,20 @@ const reactruntime = require("../../reactruntime");
class Clip extends React.Component {
constructor(props) {
super(props);
this.state = {
loading: true,
imageDisplay: "none"
};
}

componentDidMount() {
let image = ReactDOM.findDOMNode(this.refs.clipImage);
if (image.complete) {
this.setState({
loading: false,
imageDisplay: "inline"
});
}
let onResize = () => {
let windowHeight = window.innerHeight;
let paddingTop = Math.floor((windowHeight - image.height - 35) / 2);
Expand All @@ -35,17 +45,30 @@ class Clip extends React.Component {
console.warn("Somehow there's a shot without an image");
return null;
}
let node = <img style={{height: "auto", width: clip.image.dimensions.x + "px", maxWidth: "100%"}} ref="clipImage" src={ clip.image.url } alt={ clip.image.text } />;
let node = <img style={{height: "auto", width: clip.image.dimensions.x + "px", maxWidth: "100%", display: this.state.imageDisplay}} ref="clipImage" src={ clip.image.url } alt={ clip.image.text } />;
return <div ref="clipContainer" className="clip-container">
<menu type="context" id="clip-image-context">
<menuitem label="Copy Image Text" onClick={this.copyImageText.bind(this)} ></menuitem>
</menu>
<a href={ clip.image.url } onClick={ this.onClickClip.bind(this) } contextMenu="clip-image-context">
{ this.renderSpinner() }
{ node }
</a>
</div>;
}

renderSpinner() {
if (!this.state.loading) {
return null;
}
return (
<div>
Loading...
<span className="spinner" />
</div>
);
}

onClickClip() {
sendEvent("goto-clip", "content", {useBeacon: true});
// Allow default action to continue
Expand Down

0 comments on commit c53297f

Please # to comment.