Buckets:
Quantumbraid/trainingdata / ui /node_modules /react-zoom-pan-pinch /src /components /transform-wrapper /transform-wrapper.tsx
| import React, { useEffect, useImperativeHandle, useRef } from "react"; | |
| import { ZoomPanPinch } from "../../core/instance.core"; | |
| import { | |
| ReactZoomPanPinchContentRef, | |
| ReactZoomPanPinchProps, | |
| } from "../../models"; | |
| import { getControls } from "../../utils"; | |
| export const Context = React.createContext<ZoomPanPinch>(null as any); | |
| const getContent = ( | |
| children: ReactZoomPanPinchProps["children"], | |
| ctx: ReactZoomPanPinchContentRef, | |
| ) => { | |
| if (typeof children === "function") { | |
| return children(ctx); | |
| } | |
| return children; | |
| }; | |
| export const TransformWrapper = React.forwardRef( | |
| ( | |
| props: Omit<ReactZoomPanPinchProps, "ref">, | |
| ref: React.Ref<ReactZoomPanPinchContentRef>, | |
| ) => { | |
| const instance = useRef(new ZoomPanPinch(props)).current; | |
| const content = getContent(props.children, getControls(instance)); | |
| useImperativeHandle(ref, () => getControls(instance), [instance]); | |
| useEffect(() => { | |
| instance.update(props); | |
| }, [instance, props]); | |
| return <Context.Provider value={instance}>{content}</Context.Provider>; | |
| }, | |
| ); | |
Xet Storage Details
- Size:
- 1.07 kB
- Xet hash:
- 2fdec2fb9be18cb3d1e33d9ee70c01a13b201e93559ca89c3a77b1738bc137d5
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.