Skip to content

Commit

Permalink
Allow control over viewer dimensions
Browse files Browse the repository at this point in the history
  • Loading branch information
samirelanduk committed Aug 3, 2021
1 parent b5f8e44 commit 669fc55
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/Molstar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Viewer } from "molstar/build/viewer/molstar";

const Molstar = props => {

const { pdbId, url, options } = props;
const { pdbId, url, dimensions, options } = props;
const viewerElement = useRef(null);
const viewer = useRef(null);

Expand All @@ -16,14 +16,25 @@ const Molstar = props => {
return () => viewer.current = null;
}, [])

if (!dimensions) return <div ref={viewerElement} />

return (
<div ref={viewerElement} />
<div style={{
position: "relative",
width: dimensions[0], height: dimensions[1]
}}>
<div ref={viewerElement} style={{
position: "absolute",
width: dimensions[0], height: dimensions[1], left: 0, right: 0
}}/>
</div>
);
};

Molstar.propTypes = {
pdbId: PropTypes.string,
url: PropTypes.string,
dimensions: PropTypes.array,
options: PropTypes.object
};

Expand Down

0 comments on commit 669fc55

Please sign in to comment.