-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create useFlip hook #183 #215
base: main
Are you sure you want to change the base?
Conversation
const [isFlipped, toggle] = useToggle(false); | ||
|
||
const divRef = useRef<HTMLDivElement>(null); | ||
useFlip(divRef, flipOptions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flipOptions
is not defined anywhere
const flipStateRef = useRef<Flip.FlipState>(); | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
if (globalThis.window !== undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be useful (for others, or future self), to add some comments explaining how/why this works.
I assume that:
- the
if
executes before potentially new style vars are set, capturing the "current" state. - the
useEffect
executes after applying and rendering the new style vars, and then transitioning to them from the previously captured state.
|
||
<Meta title="components/useFlip" of={stories} /> | ||
|
||
# useFlip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's unclear from the (non-existing) api docs:
- what I can pass as first parameter (can it be both an element, or also a ref around an element?)
- what I can pass as second parameter (some gsap flip props?)
- If the second param is optional or required.
No description provided.