Skip to content

Commit

Permalink
BUG: Do not reference script id
Browse files Browse the repository at this point in the history
In the Colab notebook the id is never set for script for some reason. This leads
to a bug in the script that prevents the screenshot from being hidden and
incorrectly resizes the output area, forcing the user to scroll to find the
viewer.
  • Loading branch information
bnmajor committed Aug 24, 2022
1 parent bf73082 commit e81ff77
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions itkwidgets/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,9 @@ async def create_screenshot(self):
def update_screenshot(self, base64_image):
html = HTML(
f'''
<img id=screenshot_{self.wid} src={base64_image}>
<script id="script_{self.wid}" type="text/javascript">
var container = document.getElementById("script_{self.wid}").parentNode;
<img id="screenshot_{self.wid}" src={base64_image}>
<script type="text/javascript">
var image = document.getElementById("screenshot_{self.wid}");
if (!image) {{
image = document.createElement("img");
image.id = "screenshot_{self.wid}";
container.appendChild(image);
}}
image.src = "{base64_image}";
var viewer = document.getElementById("{self.wid}");
// Hide the static image if the Viewer is visible
Expand Down

0 comments on commit e81ff77

Please sign in to comment.