Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | 33x 33x 33x 33x 1358x 1358x 1358x 689x 669x 669x 1x | import { VisualElement } from "../../render/types" import { MotionProps } from "../types" import { isRefObject } from "../../utils/is-ref-object" import { IProjectionNode } from "../../projection/node/types" import { useContext } from "react" import { SwitchLayoutGroupContext } from "../../context/SwitchLayoutGroupContext" export function useProjection( projectionId: number | undefined, { layoutId, layout, drag, dragConstraints, layoutScroll }: MotionProps, visualElement?: VisualElement, ProjectionNodeConstructor?: any ) { const initialPromotionConfig = useContext(SwitchLayoutGroupContext) if ( !ProjectionNodeConstructor || !visualElement || visualElement?.projection ) { return } visualElement.projection = new ProjectionNodeConstructor( projectionId, visualElement.getLatestValues(), visualElement.parent?.projection ) as IProjectionNode visualElement.projection.setOptions({ layoutId, layout, alwaysMeasureLayout: Boolean(drag) || (dragConstraints && isRefObject(dragConstraints)), visualElement, scheduleRender: () => visualElement.scheduleRender(), /** * TODO: Update options in an effect. This could be tricky as it'll be too late * to update by the time layout animations run. * We also need to fix this safeToRemove by linking it up to the one returned by usePresence, * ensuring it gets called if there's no potential layout animations. * */ animationType: typeof layout === "string" ? layout : "both", initialPromotionConfig, layoutScroll, }) } |