-
Notifications
You must be signed in to change notification settings - Fork 312
Zoom to fit #181
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
base: main
Are you sure you want to change the base?
Zoom to fit #181
Conversation
There's no such `ui` anymore, this was replaced by `owner`. Also the optional `done` argument of internalMoveBy wasn't properly checked, triggering errors during pan navigation events. The code style was also fixed, adding ; where appropriate.
| if (!parent) | ||
| throw new Error('ui element is required to be within the scene'); | ||
|
|
||
| function centerOn(smooth) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original idea of this method was for SVG elements, that would allow clients to center on a specific element of the scene.
As the library grew this become a bit obsolete in the context of WebGL/DOM scenes (which are also supported by the library).
May I propose to keep the API, but delegate the center inference to the controller? For example, svgController API could have a method that takes the UI element and returns cx/cy, while domController does the same for the DOM nodes?
I interpret this change as a desire to zoom into the center of the actual container, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, right.
| var cy = clientRect.top + clientRect.height/2; | ||
|
|
||
| if (moveByAnimation) moveByAnimation.cancel(); | ||
| var parent = owner.parentElement.parentElement; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not following this. Why are we fetching parentElement.parentElement? Any way to avoid it?
Same applies to the use in the centerOn() method
| var wx = window.innerWidth / 2; | ||
| var wy = window.innerHeight / 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem right for the cases when container is smaller than the window
This is based on #143, with additional fixes. Please review ;)