lint fixes
This commit is contained in:
parent
a67efd0cb4
commit
e1998a8deb
5 changed files with 36 additions and 21 deletions
|
@ -1,7 +1,12 @@
|
|||
import React, { useState, useMemo } from 'react'
|
||||
import React, { useState, useMemo, useEffect } from 'react'
|
||||
|
||||
/**
|
||||
* A context for managing zoom state of a {@see PanZoomPattern}
|
||||
* Allows transform handlers to be available in components outside of the TransformWrapper without a bunch of prop drilling
|
||||
* */
|
||||
export const PanZoomContext = React.createContext({})
|
||||
|
||||
/** Provider for the {@see PanZoomContext} */
|
||||
export const PanZoomContextProvider = ({ children }) => {
|
||||
const [zoomed, setZoomed] = useState(false)
|
||||
const [_zoomFunctions, setZoomFunctions] = useState(false)
|
||||
|
@ -26,3 +31,18 @@ export const PanZoomContextProvider = ({ children }) => {
|
|||
|
||||
return <PanZoomContext.Provider value={value}>{children}</PanZoomContext.Provider>
|
||||
}
|
||||
|
||||
/**
|
||||
* A component to capture the zoom functions and set them on the zoom context
|
||||
* Place this inside of a TransformWrapper child function.
|
||||
* See {@see PanZoomPattern} for an example
|
||||
* */
|
||||
export const PanZoomCapture = ({ resetTransform, zoomIn, zoomOut, setZoomFunctions }) => {
|
||||
useEffect(() => {
|
||||
if (typeof setZoomFunctions === 'function') {
|
||||
setZoomFunctions({ resetTransform, zoomIn, zoomOut })
|
||||
}
|
||||
})
|
||||
|
||||
return <></>
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue