[fix] Fixes off-center bugs (#101)

* moves center from window center to center of element

* Removes onMount in Renderer, adds onBoundsChange

* Fix centered-g css

* Fix zoom to fit
This commit is contained in:
Steve Ruiz 2021-09-22 09:45:09 +01:00 committed by GitHub
parent 7d61d24398
commit 68efbf69fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 125 additions and 104 deletions

View file

@ -56,9 +56,13 @@ export interface RendererProps<T extends TLShape, E extends Element = any, M = a
*/
meta?: M
/**
* A callback that receives the renderer's inputs manager.
* (optional) A callback that receives the renderer's inputs manager.
*/
onMount?: (inputs: Inputs) => void
/**
* (optional) A callback that is fired when the editor's client bounding box changes.
*/
onBoundsChange?: (bounds: TLBounds) => void
}
/**
@ -83,7 +87,7 @@ export function Renderer<T extends TLShape, E extends Element, M extends Record<
}: RendererProps<T, E, M>): JSX.Element {
useTLTheme(theme)
const rScreenBounds = React.useRef<TLBounds>(null)
const rSelectionBounds = React.useRef<TLBounds>(null)
const rPageState = React.useRef<TLPageState>(pageState)
@ -96,7 +100,7 @@ export function Renderer<T extends TLShape, E extends Element, M extends Record<
const [context] = React.useState<TLContextType<T, E, M>>(() => ({
callbacks: rest,
shapeUtils,
rScreenBounds,
rSelectionBounds,
rPageState,
inputs: new Inputs(),
}))