mirror of
https://github.com/balzack/databag.git
synced 2025-02-14 12:39:17 +00:00
opps forgot to add src file
This commit is contained in:
parent
a5e4e75e2d
commit
779db5635b
@ -0,0 +1,34 @@
|
||||
import { useContext, useState, useEffect, useRef } from 'react';
|
||||
import { ViewportContext } from 'context/ViewportContext';
|
||||
|
||||
export function useImageAsset() {
|
||||
|
||||
const [state, setState] = useState({
|
||||
display: null,
|
||||
popout: false,
|
||||
width: 0,
|
||||
height: 0,
|
||||
});
|
||||
|
||||
const viewport = useContext(ViewportContext);
|
||||
|
||||
const updateState = (value) => {
|
||||
setState((s) => ({ ...s, ...value }));
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
updateState({ display: viewport.state.display });
|
||||
}, []);
|
||||
|
||||
const actions = {
|
||||
setPopout: (width, height) => {
|
||||
updateState({ popout: true, width, height });
|
||||
},
|
||||
clearPopout: () => {
|
||||
console.log("CLEAR POPOUT");
|
||||
updateState({ popout: false });
|
||||
},
|
||||
};
|
||||
|
||||
return { state, actions };
|
||||
}
|
Loading…
Reference in New Issue
Block a user