fix:解决拖拽问题
This commit is contained in:
1 parent
ce06ad0214
commit
6367014e1f
34 files changed
+1712
-397
No files matched your search
@@ -0,0 +1,31 @@
|
||||
import { createContext, useContext, ReactNode } from "react";
|
||||
|
||||
export interface ScaleContextValue {
|
||||
scale: number;
|
||||
offsetX: number;
|
||||
offsetY: number;
|
||||
DESIGN_WIDTH: number;
|
||||
DESIGN_HEIGHT: number;
|
||||
}
|
||||
|
||||
const ScaleContext = createContext<ScaleContextValue | null>(null);
|
||||
|
||||
export function ScaleProvider({
|
||||
children,
|
||||
value,
|
||||
}: {
|
||||
children: ReactNode;
|
||||
value: ScaleContextValue;
|
||||
}) {
|
||||
return (
|
||||
<ScaleContext.Provider value={value}>{children}</ScaleContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
export function useScale() {
|
||||
const context = useContext(ScaleContext);
|
||||
if (!context) {
|
||||
throw new Error("useScale must be used within ScaleProvider");
|
||||
}
|
||||
return context;
|
||||
}
|
||||
Reference in new issue
Block a user