-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not working with ShadowRoot #1003
Comments
The way the mouse events work in NGL is that they are attached on the document (not the canvas directly). I think this allows, for example, to detect when the user releases the mouse by dragging the pointer outside of the viewport. When the user clicks, the mouse down event is captured by the document. The My understanding is that the shadow root is useful for encapsulating the stylings. In the case of NGL, as there are no CSS styles applied, it seems there is no benefit. The general idea is to create a |
Thanks so much. Really appreciated. I've tried exploring this. My understanding is that this will not work for my situation because
Exampleimport panel as pn
pn.extension("ngl_viewer", sizing_mode="stretch_width")
import param
from panel.reactive import ReactiveHTML
class CustomComponent(ReactiveHTML):
index = param.Integer(default=0)
_template = """
<slot id="slot" name="slot" style="width:400px; height:400px;"></slot>
<div id="viewport" style="width:400px; height:400px;"></div>
"""
__javascript__=["https://unpkg.com/ngl@2.2.1/dist/ngl.js"]
_scripts = {
"render": """
document.body.append(viewport)
var stage = new NGL.Stage(viewport.id);
function finish(o){
o.addRepresentation("cartoon");
o.autoView();
}
stage.loadFile("rcsb://1CRN").then(finish)
host = slot.getRootNode().host
console.log(host)
host.append(viewport)
console.log(slot)
slot.assign(viewport)
"""
}
pn.Column(
"# NGL Viewer",
CustomComponent(width=400, height=400, styles={"border": "1px solid black"})
).servable() pip install panel
panel serve script.py --autoreload --show |
I'm trying to upgrade the panel-chemistry Python package to work with Panel 1.x/ Bokeh 3.x. This is done in panel-chemistry #41.
Right now I'm working on the
NGLViewer
component and I cannot get themouse
working. When I drag or zoom it does not work.The big change from Bokeh 2 to 3 is that all Bokeh components are now rendered inside shadow root. My hypothesis is that it is the cause.
I have a minimum, reproducible example below
It renders nicely. But when I try to drag or zoom nothing happens
I am a data scientist primarely fluent in Python. Javascript is not my strength.
I don't know if I can change the solution above to support mouse events. Or if something needs to change in NGL for this to ever work.
The text was updated successfully, but these errors were encountered: