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.
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?
| var cy = clientRect.top + clientRect.height/2; | ||
|
|
||
| if (moveByAnimation) moveByAnimation.cancel(); | ||
| var parent = owner.parentElement.parentElement; |
There was a problem hiding this comment.
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.
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 ;)