Skip to content

Commit

Permalink
Merge branch 'feature/iframe-throttling-fix-rebase' of github.com:Met…
Browse files Browse the repository at this point in the history
…aCell/NetPyNE-UI into feature/iframe-throttling-fix-rebase
  • Loading branch information
filippomc committed Jan 16, 2024
2 parents 7f03a5f + 071ae73 commit e96c366
Showing 1 changed file with 8 additions and 32 deletions.
40 changes: 8 additions & 32 deletions webapp/components/general/NetPyNEPythonConsole.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,36 +70,19 @@ export class NetPyNEPythonConsole extends Component {
return currentNotebookValues ;
}

componentDidUpdate (prevProps) {
document.getElementById('pythonConsoleFrame').parentElement.parentElement.style.display = 'block';
}

shouldComponentUpdate (nextProps) {
if (this.props.extensionLoaded !== nextProps.extensionLoaded) {
return true;
}
const iframeStyle = {
position: 'absolute',
left: `${offScreenLeft}px`,
width: '1px',
height: '1px',
};
var iframeWindow = this.container.contentWindow;
var iframeElement = iframeWindow.frameElement;
var parentDiv = iframeElement.parentElement;
var containerDiv = parentDiv.parentElement;
const offScreenLeft = -window.innerWidth - 100; //plus additional buffer just in case

if (nextProps.notebookVisible)
{
var iframeWindow = this.container.contentWindow;
iframeWindow.onblur = this.handleIframeBlur ;
iframeWindow.onfocus = this.handleIframeFocus ;
}
else{
iframeWindow.position = 'absolute';
iframeWindow.left = `${offScreenLeft}px`;
iframeWindow.width = '1px';
iframeWindow.height = '1px';

containerDiv.style.display = 'block';
}
return false;
return true;
}

handleIframeBlur = (event) => {
Expand All @@ -123,17 +106,10 @@ export class NetPyNEPythonConsole extends Component {

render () {
const notebookName = GEPPETTO_CONFIGURATION.notebookName || "notebook.ipynb";

return (
<ReactResizeDetector handleWidth handleHeight>
{({ width, height }) => (
<PythonConsole
pythonNotebookPath={`notebooks/${notebookName}`}
extensionLoaded={this.props.extensionLoaded}
iframeHeight={height}
/>
)}
</ReactResizeDetector>
{({ width, height }) => <PythonConsole pythonNotebookPath={`notebooks/${notebookName}`} extensionLoaded={this.props.extensionLoaded} iframeHeight={height} />}
</ReactResizeDetector>
);
}
}
Expand Down

0 comments on commit e96c366

Please sign in to comment.