-
Notifications
You must be signed in to change notification settings - Fork 296
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
what does this error "ui element is required to be within the scene" mean? #47
Comments
Did you solve the issue? |
@MohammedAbdulMateen I had the same issue, centerOn only seems to work when your panzoom scene is inside an svg, I had a case similar to yours and had to write a custom centerOn which understands something else then svg. My centerOn function looks like this: function centerOn(ui) {
const parent = ui.parentNode.parentNode;
if (!parent) throw new Error('ui element is required to be within the scene');
// TODO: should i use controller's screen CTM?
const clientRect = ui.getBoundingClientRect();
const cx = clientRect.left + clientRect.width / 2;
const cy = clientRect.top + clientRect.height / 2;
const container = parent.getBoundingClientRect();
const dx = container.width / 2 - cx;
const dy = container.height / 2 - cy;
internalMoveBy(dx, dy, true);
} but it probably only works for me, since i have that specific nesting with .parentNode.parentNode. But you can use it to write your own. |
Ideally the centerOn method accepts the parent as a second argument instead of having to figure it out, then you can remove the first 2 lines and pass parent through the arguments. Like so: function centerOn(ui, parent) {
// TODO: should i use controller's screen CTM?
const clientRect = ui.getBoundingClientRect();
const cx = clientRect.left + clientRect.width / 2;
const cy = clientRect.top + clientRect.height / 2;
const container = parent.getBoundingClientRect();
const dx = container.width / 2 - cx;
const dy = container.height / 2 - cy;
internalMoveBy(dx, dy, true);
} |
I am getting the above mentioned error with centerOn() function, what am I supposed to pass to it?
this is my HTML structure
and this is my pan zoom initializer
To centerOn() I tried sending div (.faqnode) and svg (.connector) as argument
I am using this plugin for a flow designer, and I want to show flow in the center of the screen during page load, I tried doing that using zoomAbs() and moveTo() but no luck
so I thought centerOn() will be helpful, to just center to the starting node in the diagram
please help on how I can achieve this?
The text was updated successfully, but these errors were encountered: